如何知道特定组是否存在于 ExapndableListView 中?
How to know whether particular group is exist in ExapndableListView?
因为我想这样做:
expandableListView.expandGroup(4);
并且因为有时它不存在,因为我根据用户
删除删除了header
或者告诉我另一种方式来给 pos 不硬编码
expandableListView.expandGroup(4);
编辑:
if (expandableCategoryAdapter.getGroupCount() == 5) {
expandableListView.expandGroup(4);
}
而不是 4 和 5,我想这样做取决于 adapter/list 大小。
我怎样才能做到这一点?我不想硬核 4 和 5
尝试使用此代码 → 首先您必须检查 expandableListView 有多少组。
int groupCount = expandableListView.getExpandableListAdapter().getGroupCount();
if (x < groupCount) {
expandableListView.expandGroup(x);
} else {
(your own code) }
因为我想这样做:
expandableListView.expandGroup(4);
并且因为有时它不存在,因为我根据用户
删除删除了header或者告诉我另一种方式来给 pos 不硬编码 expandableListView.expandGroup(4);
编辑:
if (expandableCategoryAdapter.getGroupCount() == 5) {
expandableListView.expandGroup(4);
}
而不是 4 和 5,我想这样做取决于 adapter/list 大小。 我怎样才能做到这一点?我不想硬核 4 和 5
尝试使用此代码 → 首先您必须检查 expandableListView 有多少组。
int groupCount = expandableListView.getExpandableListAdapter().getGroupCount();
if (x < groupCount) {
expandableListView.expandGroup(x);
} else {
(your own code) }