您可以在可展开列表视图上设置 OnItemLongClickListener。
ExpandableListView.PACKED_POSITION_TYPE_GROUP
是组的 if,将其更改为
ExpandableListView.PACKED_POSITION_TYPE_CHILD
,您可以通过长按组子项进行操作。
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) {
Toast toast = Toast.makeText(c, "Loong", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
return true;
}
return false;
}
});