<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/rv"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
NestedScrollView 嵌套RecyclerView(不管嵌套深度),setOnLoadMoreListener会不断被调用
with(viewBinding){
//内嵌在NestedScrollView,会导致onLoadMore不断被调用
rv.adapter.loadMoreModule.setOnLoadMoreListener{
onLoadMore()
}
}
解决方法:
使用ConsecutiveScrollerLayout替换NestedScrollView
<com.donkingliang.consecutivescroller.ConsecutiveScrollerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</com.donkingliang.consecutivescroller.ConsecutiveScrollerLayout>
|