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
Just a simple one! Create a dialog method, something like this anywhere in your Java class:
public void openDialog() {
final Dialog dialog = new Dialog(context); // Context, this, etc.
dialog.setContentView(R.layout.dialog_demo);
dialog.setTitle(R.string.dialog_title);
dialog.show();
}
Now create Layout XML dialog_demo.xml
and create your UI/design. Here is a sample one I created for demo purposes:
Now you can call openDialog()
from anywhere you like :) Here is the screenshot of above code.
Note that text and color are used from strings.xml
and colors.xml
. You can define your own.