How to create alert in android
Some times it is a need to popup a message as warning message or alert message for the user and also give option to the user to close that popup after reading the message.
So following the below set of code you can do it easily.
1. Initialising.
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Test Title").setPositiveButton("ok", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
2. Execution
alert.setMessage("Your Warning Message").show();
View Comments
Comment or Ask a Question
Quick Links