0

I have the following problem My list has 24 items when is showing them on the NestedScrollView - ReycleView its show 21 items and duplicate 3 of them so 24 item and 2 or 3 item are not shown instead have duplicates. This is my code I try everything from this question stackoverflow question so I don't need to share my Adapter.

XML:

  <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_noti"
            tools:listitem="@layout/rv_noti"
            android:layout_width="match_parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toTopOf="@id/txt1"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false"/>

Fragment:

public class AllFragment extends Fragment {

View view;
TextView day, notificationTitle, notificationBody;
RecyclerView rv;
ArrayList<Object> notifications;
private DBHandler dbHandler;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_all, container, false);
    rv = view.findViewById(R.id.rv_noti);

    dbHandler = new DBHandler(AllFragment.this.getContext());

    try {
        notifications = dbHandler.readCourses("Notifications");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    NotiAdapter adapter = new NotiAdapter(notifications, getContext());
    rv.setAdapter(adapter);
    rv.setLayoutManager(new LinearLayoutManager(getActivity()));

    return view;
}

}

mikegrep
  • 121
  • 9
  • And if you remove the NestedScrollView, do you still see duplicates? I want to make sure this isn't a data issue.. Double check the notifications variable content. – gioravered Sep 08 '22 at 07:31
  • I will try later if I have only rv to see if they repeating to notification list has not repeted elements – mikegrep Sep 08 '22 at 08:04
  • @gioravered So I remove the nested scroll view at first load the recycle view elements are same as with the nested scroll view but when I scroll to bottom and then to top of the screen the elements rearrange and does not repeat – mikegrep Sep 10 '22 at 08:34
  • But was data problem I was reversing the list in the adapter on create method when I move the Collection.reverse() method in the fragment it looks ok – mikegrep Sep 10 '22 at 08:40

0 Answers0