我有一个ExpandableListView
并且我需要将某个组(groupPosition 已知并且始终相同)设置为不可扩展,并且Activity
在单击时开始一个新组。有没有办法做到这一点?
更新
我也只需要一次扩展一个组,并尝试了以下方法(但这不能正常工作):
getExpandableListView().setOnGroupClickListener(
new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent,
View v, int groupPosition, long id) {
if (groupPosition == 1) {
Toast.makeText(getApplicationContext(), "TEST",
Toast.LENGTH_SHORT).show();
} else if (groupPosition != lastExpandedGroupPosition) {
getExpandableListView().collapseGroup(
lastExpandedGroupPosition);
} else
getExpandableListView().expandGroup(groupPosition);
lastExpandedGroupPosition = groupPosition;
return true;
}
});