Note that there are some explanatory texts on larger screens.

plurals
  1. POclose custom alertdialog on clicklistener
    text
    copied!<p>i have custom dialog with three button . i have click listener for 3 buttons.... here is the code.</p> <pre><code> public void addDialog() { // TODO Auto-generated method stub AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); // Setting Dialog Title alertDialog.setTitle("Add From"); // Setting Dialog Message alertDialog.setMessage("Add Number: "); LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view=layoutInflater.inflate(R.layout.dialog_lay,null); Button btn_Contact = (Button)view.findViewById(R.id.btn_contact); Button btn_SMS = (Button)view.findViewById(R.id.btn_sms); Button btn_Manually = (Button)view.findViewById(R.id.btn_manually); // Setting Negative "NO" Button alertDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event Toast.makeText(getApplicationContext(), "You clicked on NO", Toast.LENGTH_SHORT).show(); dialog.cancel(); } }); OnClickListener listenerDial = new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // i want to close alert dialog here Toast.makeText(getApplicationContext(), "You clicked contact btn", Toast.LENGTH_SHORT).show(); } }; // add listener to button. btn_Contact.setOnClickListener(listenerDial); btn_SMS.setOnClickListener(listenerDial); btn_Manually.setOnClickListener(listenerDial); alertDialog.setView(view); alertDialog.show(); } </code></pre> <p><strong>i want to close this alert dialog when any of the three key is pressed .. any suggetion plzzzz..</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload