title: Show Progressdialog on AlertDialog button click
body: <p>I want to show a ProgressDialog when the User clicks a "Ok" button on the AlertDialog. But with my current code the ProgressDialog doesnt show at all. Also the AlertDialog should dismiss after button click and the ProgressDialog should be shown. Right now the AlertDialog dismisses after button click but does not show the ProgressDialog</p>
  
  <p>Here is my code:-</p>
  
  <pre><code> case R.id.btnAddComms:
              scrollNews.fullScroll(v.FOCUS_DOWN);
              btnAddComms.setPressed(true);
  
              AlertDialog.Builder builder = new AlertDialog.Builder(NewsDetails.this);
              builder.setTitle("Post");
              builder.setIcon(R.drawable.post);
  
  
              final EditText input1 = new EditText(NewsDetails.this);
              LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                      LinearLayout.LayoutParams.MATCH_PARENT,
                      LinearLayout.LayoutParams.MATCH_PARENT);
  
              input1.setLayoutParams(lp);
              builder.setView(input1);
  
  
              builder.setPositiveButton("Ok", new DialogInterface.OnClickListener()
              {
  
                  public void onClick(DialogInterface dialog, int id) 
                  {
  
  
                       postedComment = input1.getText().toString();
  
                       if(postedComment.length()&gt;0)
                       {
                           dialog.dismiss();
                           ProgressDialog pd = new ProgressDialog(NewsDetails.this);
                           pd.setMessage("test");
                           pd.show();
                           pd.setCancelable(true);
                           PostComments(postedComment);
                           pd.dismiss();
  
                       }
                       else
                       {
                           Toast.makeText(NewsDetails.this, "Please enter a comment.", Toast.LENGTH_LONG).show();
                           input1.findFocus();
                       }
  
  
  
  
  
  
                  }
  .setCancelable(false);
  
  
  
              alert = builder.create();
              alert.setCanceledOnTouchOutside(true);
  
              alert.show();
              break;
  </code></pre>
  
  <p>Any idea on how I can do it.</p>