滚动以为RecyclerView加载更多内容

I have a JSON data which consists of 100 rows. How can I show the first 10 rows when the app is launched and subsequently additional 10 rows when users scroll towards bottom ?

All the solutions that I have found focus more on calling back to the server with the last ID.

What I would like to have is, keep appending the view from the JSON data (100 rows) which is loaded earlier when the app is launched.

Anyone knows how should I go about this ?

What I would like to have is, keep appending the view from the JSON data (100 rows) which is loaded earlier when the app is launched.

Unless I'm misunderstanding your question. RecyclerView should handle loading of data on its own.

If your data is already loaded from the server and stored on the phone, then RecyclerView would handle loading of rows, where it would only keep the rows that are shown on the screen in memory and when user scrolls (up or down) and reaches new rows it will load them and show them on the screen and remove the rows that are no longer shown. So just send all of your data (the 100 rows) to your recyclerAdapterand it will handle memory management and loading of rows automatically.

What @A.R.H answered is correct. To add furthermore, in case you need to add more elements to an adapter of the RecyclerView. ie Assume you have 100 elements in the adapter, and now you need to retrieve a 10 more, then you can use 'pull to refresh' to do so. There are various libraries available. However the one which I found pretty straightforward is : Phoenix .

And you can retrieve the data from network inside the onRefreshListener() :

mPullToRefreshView = (PullToRefreshView) findViewById(R.id.pull_to_refresh);
mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() {
    @Override
    public void onRefresh() {
        mPullToRefreshView.postDelayed(new Runnable() {
            @Override
            public void run() {
                mPullToRefreshView.setRefreshing(false);
            }
        }, REFRESH_DELAY);
    }
 });

And inside the run method you can invoke the method to retrieve the data.

Other than this, there's no need to worry about a scroll to feature; As you've asked :

I have a JSON data which consists of 100 rows. How can I show the first 10 rows when the app is launched and subsequently additional 10 rows when users scroll towards bottom ?

Unlike a ListView, RecyclerView only loads items to the memory that fits into the screen. So there is no specific need for a scroll to feature. However if for a user experience purpose, you can achieve the same using the Phoenix library. Hope it helps!