RecyclerView之下拉刷新

版权声明:转载请在开头注明博客原地址,谢谢! https://blog.csdn.net/qq_35928566/article/details/82379335

方法一:嵌套SwipeRefreshLayout

文件相关:
XML文件

    <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipeRefreshLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </android.support.v4.widget.SwipeRefreshLayout>

Activity文件:

    swipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeRefreshLayout.setRefreshing(true);
            //TODO
        }
    });

这样就在下拉的时候就可以执行相关语句刷新RecyclerView

//2018年9月4日 10:20:28 第一次更新

猜你喜欢

转载自blog.csdn.net/qq_35928566/article/details/82379335
今日推荐