Expandablelistview Ongroupclicklistener Not Firing
I'm following this: Programmatically collapse a group in ExpandableListView. I want the user capable to expand only one group at a time and smoothly scroll to the right position. I
Solution 1:
I would suggest you to check for the imports first (not shown in your question),and make sure you have imported android.widget.ExpandableListView.OnGroupClickListener
or replace : new OnGroupClickListener() {
with new android.widget.ExpandableListView.OnGroupClickListener {
EDIT :
I also noticed that you are returning 'true' at the body of boolean onGroupClick(...)
that means "the click was handled" and groups will never be collapsed, expanded.
You should return false if you want to expand.So I suggest you to do like this :
expListView.setOnGroupClickListener(newOnGroupClickListener() {
@OverridepublicbooleanonGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
Log.d("onGroupClick:", "worked");
parent.smoothScrollToPosition(groupPosition);
if (parent.isGroupExpanded(groupPosition)) {
parent.collapseGroup(groupPosition);
} else {
parent.expandGroup(groupPosition);
}
returnfalse;
}
});
Post a Comment for "Expandablelistview Ongroupclicklistener Not Firing"