Answers for "alertdialog with multicjocie example"

3

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();
        }
    }
});
Posted by: Guest on September-17-2020
0

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()
Posted by: Guest on November-10-2020

Code answers related to "alertdialog with multicjocie example"

Browse Popular Code Answers by Language