本文主要是介绍SwipeRefreshLayout 刷新的功能,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<android.support.v4.widget.SwipeRefreshLayoutandroid:id="@+id/srl"android:layout_width="match_parent"android:layout_height="wrap_content"></android.support.v4.widget.SwipeRefreshLayout>
下拉刷新,上拉加载:
mFgrlv.setOnScrollListener(new RecyclerView.OnScrollListener() {int lastVisibleItem;@Overridepublic void onScrollStateChanged(RecyclerView recyclerView, int newState) {super.onScrollStateChanged(recyclerView, newState);//判断RecyclerView的状态 是空闲时,同时,是最后一个可见的ITEM时才加载if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem + 1 == zhiBoRLVAdapter.getItemCount()) {count++;zhiBaoPersenter.getZhiBo(count + "");zhiBoRLVAdapter.notifyDataSetChanged();}}@Overridepublic void onScrolled(RecyclerView recyclerView, int dx, int dy) {super.onScrolled(recyclerView, dx, dy);LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();//最后一个可见的ITEMlastVisibleItem=layoutManager.findLastVisibleItemPosition();}});srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {@Overridepublic void onRefresh() {zhiBaoPersenter.getZhiBo(count + "");zhiBoRLVAdapter.notifyDataSetChanged();srl.setRefreshing(false);}});}
这篇关于SwipeRefreshLayout 刷新的功能的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!