I want to display a dialog/popup window with a message to the user that shows \"Are you sure you want to delete this entry?\" with one button that says \'Delete\'. When
I was using this AlertDialog in button onClick method:
button.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(this);
View view2 = layoutInflaterAndroid.inflate(R.layout.cancel_dialog, null);
builder.setView(view2);
builder.setCancelable(false);
final AlertDialog alertDialog = builder.create();
alertDialog.show();
view2.findViewById(R.id.yesButton).setOnClickListener(v1 -> onBackPressed());
view2.findViewById(R.id.nobutton).setOnClickListener(v12 -> alertDialog.dismiss());
});
dialog.xml