androidorientationexpandablelistviewchildviews

Orientation change colapsing children in ExpandableListView


I have created a ExpandableListView.

When I expanded it, its children are showing properly.

But when I change the orientation from potrait to lanscape or vice-versa the ExpandableListView remains open but its children are not showing. After clicking the layout they are showing properly..

Any answers will help me.


Solution

  • When the device is rotated, the app is restarted. So onSaveInstance is called before the app gets destroyed.

    You can save the expandable list adapter in onSaveInstance and when the onCreate is finally called when the app is started again, you can retrieve the Expandable list adapter and set it to the list view.