title: Android : AlertDialog shown twice instead of once
body: <p>I have an android app in which when the users touch or click the <code>EditText</code>, the content of the <code>EditText</code> is shown in the <code>AlertDialog</code>. I added a done <code>Button</code> to it, but the <code>AlertDialog</code> does not dismiss. I have to press the done button twice. I am not able to know why this is happening and can any anyone suggest a better alternative other than toast?</p>
  
  <p>Coding Part:
      I am calling the following  function on touch.</p>
  
  <pre><code>public void setalert()
  {
      AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
              mContext);
  
      // set title
  
  
      // set dialog message
      alertDialogBuilder
      .setMessage(etDesc.getText().toString())
      .setCancelable(false)
  
  
      .setNegativeButton("Done",new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog,int id) {
              // if this button is clicked, just close
              // the dialog box and do nothing
  
              dialog.cancel();                                                            
  
          }
      });                 
  
      // show it
      alertDialogBuilder.show();
  
  }
  </code></pre>