Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active Apr 12, 2017
Embed
What would you like to do?
onChildClick
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, final View v, final int groupPosition, final int childPosition, final long id) {
AlertDialog.Builder childContextMenuBuilder = new AlertDialog.Builder(v.getContext());
childContextMenuBuilder.setItems(R.array.dinner_child_actions, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Date date = dinnerAdapter.getGroup(groupPosition);
switch (which) {
case 0:
AlertDialog.Builder addBuilder = addNewDinnerBuilder(v, date);
addBuilder.show();
break;
case 1:
dinnerContract.deleteDinner(id, dbHelper);
dinnerAdapter.updateResults(dinnerContract.getDinners(dbHelper));
break;
case 2:
Dinner dinner = dinnerAdapter.getChild(groupPosition, childPosition);
AlertDialog.Builder editBuilder = addNewDinnerBuilder(v, date, dinner);
editBuilder.show();
break;
}
}
});
childContextMenuBuilder.show();
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment