zoukankan      html  css  js  c++  java
  • SwipeRefreshLayout 配合fragment 下拉刷新的使用,超级简单

    前台demo

    <android.support.v4.widget.SwipeRefreshLayout
    android:layout_width="match_parent"
    android:id="@+id/swipe_container"
    android:layout_height="wrap_content"
    >
    <ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/test_record"
    android:layout_marginBottom="50dp"
    >
    </ListView>

    </android.support.v4.widget.SwipeRefreshLayout>

    后台的demo
    因为界面是fragment 并不是一个activity,所以后台demo写在了
    public void onActivityCreated(@Nullable Bundle savedInstanceState){}
    这个方法里面了,核心demo具体如下:
    注意事项,我原来一直无法刷新,是因为在方法onRefresh,里面没有写加载数据的方法,仔细想一想,
    做刷新处理,肯定是请求数据,所以,initScore(); 这个方法是直接请求数据。加进去就OK 了。

    mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
    mSwipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
    my_record.setText("正在刷新");
    // TODO Auto-generated method stub
    test_type.clear();
    test_score.clear();
    test_time.clear();
    initScore();
    new Handler().postDelayed(new Runnable() {

    @Override
    public void run() {
    // TODO Auto-generated method stub
    my_record.setText("刷新完成");
    mSwipeLayout.setRefreshing(false);
    }
    }, 6000);
    }
    });

  • 相关阅读:
    【POJ 2044】 Weather Forecast
    【POJ 1703】 Find them,Catch them
    【SCOI 2005】 骑士精神
    字长与指针
    XModem协议
    SecureCRT乱码问题解决方法
    usb设备驱动程序
    如何检测 51单片机IO口的下降沿
    matlab神经网络工具箱创建神经网络
    九针串口接线问题, 232, 485
  • 原文地址:https://www.cnblogs.com/dreamboy1992/p/6600946.html
Copyright © 2011-2022 走看看