SwipeRefreshLayout简单使用
简单的下拉刷新控件..在suportv4中
//控件包住的内容进行刷新 <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh_widget" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v7.widget.RecyclerView android:id="@+id/home_recycler_view" android:scrollbars="vertical" android:background="#f1f1f1" android:layout_width="match_parent" android:layout_height="match_parent"/> </android.support.v4.widget.SwipeRefreshLayout>
简单使用
//设置下拉刷新监听..异步拉取数据..数据处理完毕停止刷新 mSwipeRefreshWidget.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Logger.w("正在调刷新哦", "......"); UIUtils.Toastshort(mActivity, "我开始刷新了哦"); new Thread() { @Override public void run() { super.run(); try { sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } mActivity.runOnUiThread(new Runnable() { @Override public void run() { //停止刷新 mSwipeRefreshWidget.setRefreshing(false); } }); UIUtils.Toastshort(mActivity, "刷新成功"); } }.start(); } });