tags:

views:

33

answers:

2

hai,

can i set an onclickListner for AlertDialog ?

Regards Aneesh

A: 

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
Tony