How to add Alert Dialog with three Buttons in android

0 600

Alert Dialog with three Buttons

Previously we learned how we can add two buttons to alert dialog box,in this tut, I will teach you how can add Alert Dialog with three Buttons .

MainActivity.java

In main activity we will call alertdialog for alert message interface and will sill set setMessage(“Press any button”)

  • .setIcon(R.drawable.ic_launcher)
  • .setTitle(“alert box”)
  • .setPositiveButton(“Yes”, this)
  • .setNegativeButton(“No”, this)
  • .setNeutralButton(“Cancel”, this)
  • .setCancelable(false)

And onClick method will use switch statement to show a user what he slected or pressed button.

Activity_mian.xml

We have a simple Relative layout with one button and text view

Download source code

 

 

Comments

comments

Leave A Reply

Your email address will not be published.