How to Show Alert Dialog in Android
1
Import the AlertDialog class to your Android application.import android.app.AlertDialog;
2
Set up the AlertDialog class to the body of your application like this. Set some properties for the AlertDialog object.
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Reset...");
alertDialog.setMessage("Are you sure?");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
}
});
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
3
Save your application and run. You will get the image as below.
No comments:
Post a Comment