在ExpandableListView中禁用一个项目

时间:2014-04-04 11:23:23

标签: android expandablelistview

需要从ExpandableListView箭头图片中的一个项目中移除并展开此项目的可能性。 我覆盖:

@Override
public int getGroupType(int groupPosition) {
    String headerTitle = (String) getGroup(groupPosition);
    if(headerTitle.equals("History")) {
        return TYPE_SEPARATOR;
    }
    return TYPE_ITEM;
}

getGroupView我切换getGroupType(groupPosition)并选择布局 现在我的项目有我需要的布局,但它仍然是xpandable。 怎么解决? 就像是: enter image description here

1 个答案:

答案 0 :(得分:0)

expandableList.setOnGroupClickListener(new OnGroupClickListener() {
  @Override
  public boolean onGroupClick(ExpandableListView parent, View v,
                              int groupPosition, long id) { 
if(groupPosition==1)
   return true; // This way the expander cannot be collapsed
else
   return parent.isGroupExpanded(groupPosition);
      }
});
相关问题