alertdialog with multicjocie example

Example 1: android dialog box example

runOnUiThread(new Runnable() {
    @Override
    public void run() {

        if (!isFinishing()){
            new AlertDialog.Builder(YourActivity.this)
              .setTitle("Your Alert")
              .setMessage("Your Message")
              .setCancelable(false)
              .setPositiveButton("ok", new OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      // Whatever...
                  }
              }).show();
        }
    }
});

Example 2: how to do multiple button dialog kotlin

// kotlin code alert dialog builder with multiple buttons
// context = this or applicationContext
val dialog = AlertDialog.Builder(context)
val bNames = arrayOf<CharSequence>("button 1", "button 2", "button 3")
dialog.setTitle("CHOOSE ACTION")
dialog.setItems(bNames) { _, which ->
  when (which) {
    0 -> Toast.makeText(context, "clicked 1", Toast.LENGTH_SHORT).show();
    1 -> Toast.makeText(context, "clicked 2", Toast.LENGTH_SHORT).show();
    2 -> Toast.makeText(context, "clicked 3", Toast.LENGTH_SHORT).show();
  }
}.create()
// for more actions...
dialog.setNegativeButton("Cancel") { _, _ -> }
dialog.show()