android - 以编程方式展开 ExpandableListView 中的特定组
问题描述
[我的问题不重复,因为我没有使用 ImageView] 我尝试了以下方法,但它扩展了所有组
//method to expand all groups
private void expandAll() {
int count = expandableCategoryAdapter.getGroupCount().;
for (int i = 0; i < count; i++) {
expandableListView.expandGroup(i);
}
}
解决方案
在这里,您明确地扩展了所有组,ExpandableListView
这就是所有组都被扩展的原因。
不要使用这个:
//method to expand all groups
private void expandAll() {
int count = expandableCategoryAdapter.getGroupCount();
for (int i = 0; i < count; i++) {
expandableListView.expandGroup(i);
}
}
用这个 :
expandableListView.setOnGroupClickListener((parent, v, groupPosition, id) -> {
expandableListView.expandGroup(groupPosition);
return false;
});
推荐阅读
- javascript - 我正在尝试制作公会添加消息
- google-bigquery - BigQuery 地理函数 - 如何计算到多边形周长的最短距离
- php - 我不能作曲家安装 magento/extension-b2b
- sql - 聚合查询与数学中的条件
- php - 将数据时间字符串转换为日期时间
- python - 在无限循环中休眠多长时间会影响 CPU 使用率吗?
- c# - 如何使用 Azure Mgmt SDK fluent 获取空资源组列表
- sql - 如何转置结果?
- swift - 如何在核心数据 xcdatamodel 中设置 UUID 属性的默认值
- python - 神经网络训练的准确性保持不变