嗨,当recyclerview
首次创建OnbindViewHolder
直到recyclerview
中的最后一个项目被调用时,我滚动时遇到了一个奇怪的问题
OnbindViewHolder
未调用我需要解决此问题,因为我需要使用分页,但是在使用它时,它从第一次调用了所有页面
这是OnbindViewHolder
函数
@Override
public void onBindViewHolder(@NonNull EnglishNewsViewHolder holder, int position) {
Log.d("bbb", holder.getAdapterPosition() + "");
if ((((getItemCount()) - 1) - holder.getLayoutPosition() < 5) && !noMoreDate) {
loadMoreDate();
}
这就是我将项目添加到适配器
的方式 public void add(NewsModel model, int i) {
dataList.add(model);
notifyItemInserted(i);
}
这是立即创建视图而不滚动的日志。
08-18 19:58:49.958 7956-7956/qatar2022.com.qatar2022 D/bbb: 0
08-18 19:58:49.979 7956-7956/qatar2022.com.qatar2022 D/bbb: 1
08-18 19:58:49.991 7956-7956/qatar2022.com.qatar2022 D/bbb: 2
08-18 19:58:50.006 7956-7956/qatar2022.com.qatar2022 D/bbb: 3
08-18 19:58:50.020 7956-7956/qatar2022.com.qatar2022 D/bbb: 4
08-18 19:58:50.032 7956-7956/qatar2022.com.qatar2022 D/bbb: 5
08-18 19:58:50.047 7956-7956/qatar2022.com.qatar2022 D/bbb: 6
08-18 19:58:50.062 7956-7956/qatar2022.com.qatar2022 D/bbb: 7
08-18 19:58:50.077 7956-7956/qatar2022.com.qatar2022 D/bbb: 8
08-18 19:58:50.095 7956-7956/qatar2022.com.qatar2022 D/bbb: 9
08-18 19:58:50.112 7956-7956/qatar2022.com.qatar2022 D/bbb: 10
08-18 19:58:50.126 7956-7956/qatar2022.com.qatar2022 D/bbb: 11
08-18 19:58:50.139 7956-7956/qatar2022.com.qatar2022 D/bbb: 12
08-18 19:58:50.152 7956-7956/qatar2022.com.qatar2022 D/bbb: 13
08-18 19:58:50.164 7956-7956/qatar2022.com.qatar2022 D/bbb: 14
08-18 19:58:50.178 7956-7956/qatar2022.com.qatar2022 D/bbb: 15
08-18 19:58:50.194 7956-7956/qatar2022.com.qatar2022 D/bbb: 16
08-18 19:58:50.205 7956-7956/qatar2022.com.qatar2022 D/bbb: 17
08-18 19:58:50.215 7956-7956/qatar2022.com.qatar2022 D/bbb: 18
答案 0 :(得分:0)
最后,我发现我必须实现nestedScrollListener
的解决方案,因为recyclerview
的滚动行为在NestedScrollView
内部