CymChad / BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter
http://www.recyclerview.org/
MIT License
24.34k stars 5.16k forks source link

连续自动加载更多 #204

Closed lhtong closed 8 years ago

lhtong commented 8 years ago

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

    <android.support.v7.widget.RecyclerView
         android:id="@+id/recycler_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
    </android.support.v7.widget.RecyclerView>

</android.support.v4.widget.NestedScrollView> RecyclerView做了分页请求处理,当RecyclerView被NestedScrollView包含时,连续自动加载更多,直到分页数据全部加载完成。若是RecyclerView独立使用,加载更多功能正常。

主要代码: image

lhtong commented 8 years ago

@CymChad

keluokeda commented 8 years ago

@lhtong NestedScrollView  嵌套RecyclerView 会导致 RecyclerView的item全部绘制出来。超出屏幕的 item会在 NestedScrollView屏幕外面。在这种嵌套情况下RecyvlerView的高度是无限的,recyclerview 刷新机制是 最下面可见的item+pageSize>totalItem,这样就会一直触发刷新机制。不建议NestedScrollView 或者ScrollView嵌套 可复用View(ListView RecyclerView)

peter100u commented 7 years ago

我也遇到了,怎么解决?

RahulSDeshpande commented 6 years ago

Same issue everywhere :)

Reason: As NextedScrollView won't let recycle the items of RecyclerView & loads all the items in one shot, pull-up refresh won't work.

Workaround: We need to manually/listen-to monitor the NestedScrollView's scrolling event & do the load-more-items thing in child's RecyclerView. i.e., as soon the NestedScrollView scrolls to its last, callback the RecyclerView's adapter & load items.

Will post the working solution or 'proof of concept', as soon as I am done with it.

:+1: Cheers !!

@CymChad Amazing lib !! :100: