<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/id_swipe_ly"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/id_listview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.haoyouliebiaoshuaxin);//实例化
//handler 用来更新UI的
haoyouhandler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
//要做的事
Item i1 = new Item();
i1.name = "呵呵";
i1.account = 25566;
haoyou.add(i1);
Item i2 = new Item();
i2.name = "哈哈";
i2.account = 25577;
haoyou.add(i2);
haoyouadpter = new liebiaoAdapter(MainActivity.this, R.layout.liebiao, haoyou);
haoyoulist.setAdapter(haoyouadpter);
//取消更新的动画
mSwipeLayout.setRefreshing(false);
}
};
//设置监听器
mSwipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
//正在更新的时候执行什么代码
public void onRefresh() {
new Thread(new Runnable() {
@Override
public void run() {
//等待一秒
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//发消息给handler更新UI
Message ok = new Message();
haoyouhandler.sendMessage(ok);
}
}).start();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有