Issue
Hi i am facing a strange problem when the recyclerview
create first time OnbindViewHolder
called until last item in recyclerview
then when i scroll
OnbindViewHolder
not Called i need to solve this problem because i need to use pagination but when use it it called all pages from the first time
this is OnbindViewHolder
function
@Override
public void onBindViewHolder(@NonNull EnglishNewsViewHolder holder, int position) {
Log.d("bbb", holder.getAdapterPosition() + "");
if ((((getItemCount()) - 1) - holder.getLayoutPosition() < 5) && !noMoreDate) {
loadMoreDate();
}
and this is how i add the items to the adapter
public void add(NewsModel model, int i) {
dataList.add(model);
notifyItemInserted(i);
}
and this is the Log after creating view immediately without scrolling.
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
Solution
finally i found the solution i have to implement nestedScrollListener
because scrolling behaviors for the recyclerview
not working of it's inside NestedScrollView
Answered By - Mohammad Sommakia
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.