mohammedsuhail
mohammedsuhail

Reputation: 701

onclickListner for AlertDialog

Can I set an onclickListner for AlertDialog?

Upvotes: 0

Views: 667

Answers (1)

Tony
Tony

Reputation: 1576

There are three types of button in AlertDialog: positive button, negative button and neutral button. You can set click listener for each of them. AlertDialog.Builder provides a easy way to create AlertDialog, and apis to let you set listeners for those three buttons which I just mentioned. These listeners must implements DialogInterface.OnClickListener.

Following are three methods you can use to set listeners for dialog buttons:

  • AlertDialog.Builder.setPositiveButton
  • AlertDialog.Builder.setNegativeButton
  • AlertDialog.Builder.setNeutralButton

Upvotes: 3

Related Questions