是否可以在 Android 中保存和恢复 ExpandableListView 的状态(哪些项目折叠,哪些不折叠)?
如果可以的话,我该怎么做?
我可以在 onPause() / onResume() 中访问 ExpandableListView 以及如何访问?
我遍历这些组并保存所有组的状态:
int numberOfGroups = MyExpandableListViewAdapter.getGroupCount();
boolean[] groupExpandedArray = new boolean[numberOfGroups];
for (int i=0;i<numberOfGroups;i++)
groupExpandedArray[i] = MyExpandableListView.isGroupExpanded(i);
然后恢复状态:
for (int i=0;i<groupExpandedArray.length;i++)
if (groupExpandedArray[i] == true)
MyExpandableListView.expandGroup(i);
我不明白如何在 onPause() / onResume() 中访问 ListView 的意思,如果您将 ListView 对象存储为活动类的成员,则应该可以从那里访问它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)