ExpandableLists in Android, I want to allow only one parent list to expand at a time

后端 未结 8 1669
难免孤独
难免孤独 2021-02-04 17:15

I want to make only one item in the parent list expand at a time, my code for the onCreate is currently the following. (It works as I want, But the method to allow only one pare

8条回答
  •  滥情空心
    2021-02-04 17:42

    Modified the answer from Iram: So you can reopen the same Group

    // Listview Group expanded listener
        expListView.setOnGroupExpandListener(new OnGroupExpandListener() {
    
            @Override
            public void onGroupExpand(int groupPosition) {
                if (prevouriousExpandedGroupNumber != -1 && prevouriousExpandedGroupNumber != groupPosition) {
                    expListView.collapseGroup(prevouriousExpandedGroupNumber);
                }
                prevouriousExpandedGroupNumber = groupPosition;
            }
        });
    

提交回复
热议问题