Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active Apr 4, 2017
Embed
What would you like to do?
listView actions
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Button deleteMealButton = (Button) findViewById(R.id.delete_meal_button);
if (listView.getCheckedItemCount() == 0) {
deleteMealButton.setVisibility(View.INVISIBLE);
} else {
deleteMealButton.setVisibility(View.VISIBLE);
}
}
});
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Meal meal = adapter.getItem(position);
final AlertDialog.Builder builder = getAlertBuilder(view, mealContract, meal);
builder.show();
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment