1

While scrolling the page, onBindViewHolder() is not calling.

mAdapter.notifyDataSetChanged() is not updating the data correctly because of Scrollview. I checked only 3 Checkbox in Recycler. After the loading of 2nd set of data and calling the notifier more checkbox got checked irrelevantly still the data is coming from Model class correctly.

I can't share the code here, because of security reasons. I already spent a day to fix. Not fixed yet.

Then I tried removing the scrollview, it worked.

I have another few more view to fit inside the scroller. So I added that as a layout and added in the first position of Recycler. It worked. But from fragment whenever I want only that time it should come. Is there any way to fix atleast this way.

Abish R
  • 1,537
  • 3
  • 18
  • 36

2 Answers2

0

I think you should replace ScrollView with android.support.v4.widget.NestedScrollView

for example:

<?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true" >

    <android.support.design.widget.AppBarLayout
                android:id="@+id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="@dimen/app_bar_height"
                android:fitsSystemWindows="true"
                android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
                        android:id="@+id/toolbar"
                        android:layout_width="match_parent"
                        android:layout_height="?attr/actionBarSize"
                        app:layout_collapseMode="pin"
                        app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" >

    <!-- Place RecyclerView in here-->

    </android.support.v4.widget.NestedScrollView>

    </android.support.design.widget.CoordinatorLayout>
0

@Ogande, Thanks. I tried your code. Same thing is happening. So I tried with different solution, as I mentioned in my question.

I removed the scrollview and kept only Recyclerview.

I added two layouts in my Adapter. So whenever I want to add the new layout I am passing a boolean value from the fragment to the adapter as true and at the starting all the position will take default value as false. So notifychanged() will reflect the change to the adapter with that new layout.

It worked nicely as I expected.

Abish R
  • 1,537
  • 3
  • 18
  • 36