Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int viewId = view.getId();
if (viewId == R.id.text1) {
Ingredient ingredient = adapter.getItem(position);
final AlertDialog.Builder builder = getAlertBuilder(view, ingredientContract, ingredient);
builder.show();
} else if (viewId == R.id.checkBox) {
adapter.getItem(position).setChecked(!adapter.getItem(position).isChecked());
adapter.notifyDataSetChanged();
deleteButton.setVisibility(adapter.isAnyItemSelected() ? View.VISIBLE : View.INVISIBLE);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment