Abish R Abish R - 1 month ago 17
Android Question

Recyclerview inside a Scrollview not calling the Custom Adapter Function (onBindViewHolder)

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.

Answer

@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.