Disable collapsing of ExpandableListView

不想你离开。 提交于 2019-12-04 22:46:43

You can ignore click on group items like this:

mMyExpandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
  @Override
  public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
      // Doing nothing
    return true;
  }
});

Maybe It`s too late,I use onGroupCollapseListener in the activity and implement onGroupCollapse Method.(expandView is ExpandableListView)

@Override
public void onGroupCollapse(int collapseIndex) {
    expandView.expandGroup(collapseIndex);
}
user3710385

You can use this code on the item for which you want to disable clicking on: {convertView.setClickable(false);}

It seems the problem had to do with there being both a focusable element in the group header and an OnGroupClickListener set. Removing the listener solved my problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!