Creating Dialog Box in Android

AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setCancelable(false);
dialog.setTitle("Dialog on Android");
dialog.setMessage("Are you sure you want to delete this entry?");
dialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int id) {
        //Action for "Delete".
    }
})
.setNegativeButton("Cancel ", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        //Action for "Cancel".
    }
});
final AlertDialog alert = dialog.create();
alert.show();

Comments

Post a Comment

Popular posts from this blog

Temperature and Humidity in Arduino & NodeMCU

Connecting Arduino & NodeMCU with WiFi