tual.wwwturi.com
android studio alert dialog boximport android.os.Bundle;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
// Create the object of AlertDialog Builder class
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("AlertDialog Message");
builder.setTitle("AlertDialog Title");
builder.setCancelable(false);
builder.setPositiveButton("Yes",, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(AccountActivity.this, R.string.log_out_success,
Toast.LENGTH_LONG).show();
// When the user click yes button
// then app will close
finish();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel(); // if user click no button ,then cancel the dialog box
}
});
// Create the Alert dialog
AlertDialog alert = builder.create();
alert.show(); // show the Alert Dialog