0

RealmRecyclerView 我想在顶部而不是底部加载更多数据如何设置 RealmRecyclerView 默认在顶部加载更多。

4

1 回答 1

1

如果您想通过在 RecyclerView 中向上滑动来加载更多数据,我认为SwipeRefreshLayout是一个不错的选择。它很容易实现,并且在使用加载器滑动时也能提供有效的回调。请参考以下代码作为参考:

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

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:overScrollMode="never" />
        </android.support.v4.widget.SwipeRefreshLayout>

回调方法:

 swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // Refresh items
        }
    });

希望这会帮助你。

于 2017-02-21T14:19:01.477 回答