我有這種情況。我實施了endless scrolling with RecyclerView。通常情況下,噹噹前滾動位置以下只有5個項目時,新項目會被加載,但事實並非如此。無盡的RecyclerView Loading繼續加載而不滾動
相反,只要從API加載第一組項目,就會發送另一個項目(不滾動),接收並解析。之後又發送另一個請求(仍然沒有滾動)並解析。這個過程繼續(不滾動),直到應用程序退出。
我RecyclerView
mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new FadeInLeftAnimator());
recyclerView.setNestedScrollingEnabled(false);
adapter = new PostAdapter(mPostItemList, getActivity());
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(mLayoutManager) {
@Override
public void onLoadMore(final int page, int totalItemsCount, RecyclerView view) {
Log.w(TAG, "onLoadMore called");
morePostsUrl = postUrl + "&page=" + page;
getMorePostArray(morePostsUrl, true, false);
}
});
請試試這個:http://stackoverflow.com/questions/26543131/how-to-implement-endless-list-with-recyclerview – Michael