Nested RecyclerViews : Cannot call notifyDataSetChanged() method while RecyclerView is computing a layout or scrolling

Ask A Question

Login To post a question

I have to do nested RecyclerView.
I have a big list : list_one, which contains a title and another list, list_two, which contains a String and a CheckBox.

When setting up a list_two, if the String is selected (by default), I want to call the adapter of list_one to add an item, and call notifyDataSetChanged().

But, when I do that, I get an exception :

Cannot call this method while RecyclerView is computing a layout or scrolling.

I think that it’s because the list_two did not charged completely yet, so the size of list_one is not set correctly.

Is there a way to wait until the list_two charged completely, to call notifyDataSetChanged in the first list ?

Here is a picture to help you visualize the lists goal :
enter image description here

The first_list contains “Couleur”, “Taille” and “Test”.

The second_list of the first_list first item contains “Bleu”, “Rouge” and “Vert” (pretty confusing, I know)

For example, if I select “Rouge”, the first_list needs to refresh to add or delete some items that are not compatible with “Rouge”.
That’s why I need to do this trick.

Thanks for your attention.

For more info please click here

Have a question or need a custom quote?