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
The problem was solved by creating a public explist variable called list, and then referencing it to the adapter in view with the following call.
list = getExpandableListView();
The expand method before was crashing the app because of this. After refferencing the list.collapsegroup in, it worked fine.
public void onGroupExpand(int groupPosition) {
System.out.println("GROUP LISTENER WORKS?");
if(adptr=="expListAdapter"){
int len = expListAdapter.getGroupCount();
//System.out.println(len);
for (int i = 0; i < len; i++) {
if (i != groupPosition) {
list.collapseGroup(i);
}
}
}
else if(adptr=="expListAdapter2"){
int len = expListAdapter2.getGroupCount();
for (int i = 0; i < len; i++) {
if (i != groupPosition) {
list.collapseGroup(i);
}
}
//System.out.println(len);
}
else if(adptr=="expListAdapter3"){
int len = expListAdapter3.getGroupCount();
for (int i = 0; i < len; i++) {
if (i != groupPosition) {
list.collapseGroup(i);
}
}
}
}