Preserve extended group status when viewing a list of expandable data lists

When the user clicks on the group row, the list of children expands and displays. When I add any group item to Arraylist and notifyDataSetChanged () method call ; Group Expanded Status wrong .. how to fix

Example: The current position of group 1 (parent 2) is expanded. When I add the parent of group 0 to the first one and call notifyDataSetChanged (); ... parent 2 is collapsing and parent 1 is expanding. How to keep parent 2 expaded

enter image description here

Sorry my english is not very good.

+1


source to share


1 answer


when you want to add parent and its children before,

1.simply take all current parents and their children into one temporary list

2.clear the current completed list.

3.add new parent and their children to list them (which we clean up).



4. Now add the temporary list to our current list (to which we add the new parent and their children)

Now use the new populated list for the extensible list adapter

6. Show your temporary list.

0


source







All Articles