要解決ExpandableListView的點擊事件,可以通過設置ExpandableListView的OnChildClickListener和OnGroupClickListener來實現。具體步驟如下:
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view, int groupPosition, long id) {
// 處理組項點擊事件
return false;
}
});
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long id) {
// 處理子項點擊事件
return false;
}
});
通過以上步驟,可以實現對ExpandableListView的點擊事件進行處理。