I have a list, I'd like to allow user to delete an item using long click and edit when click.
The problem is, if user would like to delete an item (long click on the item) my app will open the delete confirmation message and also the edit confirmation too.
Any ideas how to open only the delete (setOnItemLongClickListener) message when user long click a list item?
// DELETE
list.setOnItemLongClickListener((parent, view, position, arg3) -> {
Contacts contacts = queue.get(position);
AlertDialog.Builder adb=new AlertDialog.Builder(Read.this);
adb.setTitle("Delete?");
adb.setMessage("Are you sure you want to delete?");
adb.setNegativeButton("Cancel", null);
adb.setPositiveButton("Ok", (dialog, which) -> {
deleteContact(Read.this, contacts.phone, contacts.name);
mobileArray.remove(position);
adapter.notifyDataSetChanged();
});
adb.show();
return false;
});
// EDIT
list.setOnItemClickListener((parent, view, position, arg3) -> {
Contacts contacts = queue.get(position);
AlertDialog.Builder adb=new AlertDialog.Builder(Read.this);
adb.setTitle("Edit?");
adb.setMessage("Edit?");
adb.setNegativeButton("Cancel", null);
adb.setPositiveButton("Ok", (dialog, which) -> {
Log.d("edit:", contacts.name + contacts.id + contacts.phone + contacts.email);
});
adb.show();
});