title: Cancel AsyncTask with Progress Dialog button
body: <p>I need to cancel my AsyncTask with a button in the progress dialog.</p>
  
  <p>I've created the Progress dialog with the button.
  Here it is:</p>
  
  <pre><code>@Override
  protected void onPreExecute() {
      pDialog = new ProgressDialog(DSDactivity.this);
      pDialog.setMessage(getResources().getString(R.string.pDialog));
      pDialog.setCancelable(false);
      pDialog.setButton("Cancel", new OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
              pDialog.dismiss();
              asyncCodelist.cancel(true);
  
          }
      });
      pDialog.show();
  }
  </code></pre>
  
  <p>I have two problems:</p>
  
  <ol>
  <li><p>When I click "cancel" on the progress dialog is removed but the async
  task continues to do what he was doing</p></li>
  <li><p>Eclipse gives me this waning:</p></li>
  </ol>
  
  <p><em>The method setButton(CharSequence, DialogInterface.OnClickListener) from the type AlertDialog is 
   deprecated</em></p>