I use a ExpandableListView
in my Android application an want to perfrom an action if the user clicks long on the group element, so I defined a OnLongClickListener
in my BaseExpandableListAdapter
extention. The listener works as aspected but the child elements does not expand anymore. Any ideas?
public class ConnectionAdapter extends BaseExpandableListAdapter {
...
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
// convertView is a LinearLayout
convertView.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
// my action here
return true;
}
});
}
...
}
You can set setOnItemLongClickListener on your expandablelistview. ExpandableListView.PACKED_POSITION_TYPE_GROUP is the id of a group, change it to ExpandableListView.PACKED_POSITION_TYPE_CHILD and you can manipulate with longclicks on group childs.
Something like that:
pager_income = (ExpandableListView) findViewById(R.id.income_scroll);
pager_income.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
// Your code with group long click
return true;
}
return false;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With