コード例 #1
0
  /** 点击了 Group 触发的事件 , 要根据根据当前点击 Group 的状态来 */
  @Override
  public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
    if (mAdapter.getHeadViewClickStatus(groupPosition) == 0) {
      mAdapter.onHeadViewClick(groupPosition, 1);
      parent.expandGroup(groupPosition);
      parent.setSelectedGroup(groupPosition);

    } else if (mAdapter.getHeadViewClickStatus(groupPosition) == 1) {
      mAdapter.onHeadViewClick(groupPosition, 0);
      parent.collapseGroup(groupPosition);
    }

    // 返回 true 才可以弹回第一行 , 不知道为什么
    return true;
  }
コード例 #2
0
  /** 点击 HeaderView 触发的事件 */
  private void headerViewClick() {
    long packedPosition = getExpandableListPosition(this.getFirstVisiblePosition());

    int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);

    if (mAdapter.getHeadViewClickStatus(groupPosition) == 1) {
      this.collapseGroup(groupPosition);
      mAdapter.onHeadViewClick(groupPosition, 0);
    } else {
      this.expandGroup(groupPosition);
      mAdapter.onHeadViewClick(groupPosition, 1);
    }

    this.setSelectedGroup(groupPosition);
  }