I am a beginner in android and I trying to make use of ExpandableListView
and was having a some issues.
I have a setOnGroupClickListner
event in my Activity for the ExpandableListView
. For some reason when I click the group, it renders the childView twice
, and in order to close it, I have to click twice. On each click only one of the childView
gets hidden.
The following was my code
expandableListView = (ExpandableListView) findViewById(R.id.alarm_list);
alist = new Alist(this, headings, childItems);
expandableListView.setAdapter(alist);
//setting an expand group listener
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
Log.e("onGroupClick:", "worked");
parent.expandGroup(groupPosition);
return false;
}
});
Now I somehow could resolve this issue if instead of return false
, I write return true
in the onGroupClick
function.
Can someone explain me what effect does it have to resolve the issue? I read somewhere that if I return true
, it means that the click was handled
, but I an not able understand what it exactly means.
Any help is appreciated. Thanks in advance
I haven't used
ExpandableListView
, but to me it looks like you don't have tosetOnGroupClickListener
explicitly, because it's automatically done for you. If you still need to change the default behavior, then you're free to override it, but you need to return true to signalize that the event is consumed and the default event will not be fired.