gpt4 book ai didi

android - 如何保持 ExpandableListView 处于展开状态?

转载 作者:IT王子 更新时间:2023-10-28 23:33:19 25 4
gpt4 key购买 nike

我用

SimpleExpandableListAdapter

在我的

ExpandableListActivity

当用户单击组行时,子列表被展开并显示,当用户单击展开列表中的每个子项时,用户将被导航到下一个second_Activity。目前,当用户单击后退按钮从 second_Activity 返回到 ExpandableListActivity 时,可展开列表初始化为未展开,我希望可展开列表保持展开状态,以便用户事先知道他选择了哪个项目。怎么做?应该覆盖 ExpandableListActivity 中的哪个方法?

PS:我知道我应该把 getExpandableListView().expandGroup(groupPosition); 放在某个地方,但是在哪里呢?我试图将此代码放在 onGroupClick()onChildClick() 中,但这没有帮助。

最佳答案

对于总是展开的组,我扩展了 SimpleExpandableListAdapter 并在 getGroupView 方法中设置要展开的组:

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View v = super.getGroupView(groupPosition, isExpanded, convertView, parent);
ExpandableListView eLV = (ExpandableListView) parent;
eLV.expandGroup(groupPosition);
return v;
}

关于android - 如何保持 ExpandableListView 处于展开状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3988337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com