title: How to show a Progress Bar inside an AlertDialog Builder along with other elements without an XML?
body: <p>I am trying to create an AlertDialog for a Bluetooth transfer after the transfer notification is touched in an android phone.</p>
  
  <p>I am trying something like this:
  Out of the below, I am getting everything - icon, title and two buttons. I am sure I can add other info like From, FileName and others using cursors with the help AlertDialog.Builder properties. I just do not know to get a progress-bar in it. I do not want to use an XML.</p>
  
  <pre><code>protected Dialog onCreateDialog(int id) {
      AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
      alertDialogBuilder.setIcon(R.id.imageFile);
      alertDialogBuilder.setTitle("File Transfer");
  
      ProgressDialog progressDialog;
      Context mContext = null;
      progressDialog = new ProgressDialog(mContext);
      progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  
      //alertDialogBuilder.setView(progressDialog); //STUCK HERE
      //"!" icon and "File Transfer"
      //from : device name
      //File: &lt;name&gt;
      //Type: &lt;type&gt; (&lt;size&gt;)
      //Receiving/Sending File
      //&lt;%&gt; | Green progress bar
      //Hide and Stop buttons
  
      alertDialogBuilder.setPositiveButton("STOP", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
          }
      });
      alertDialogBuilder.setNegativeButton("HIDE", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
          }
      });
      AlertDialog alertDialog = alertDialogBuilder.create();
      return alertDialog;
  
  }
  </code></pre>
  
  <p>I have everything in place except I am not able to figure out how to bring a progress-bar here. </p>
  
  <p>Can I getjust a progress-bar using XML layout and use as </p>
  
  <p><code>alertDialogBuilder.setView(R.id.what-ever-xml-file)</code>
  Or how to create a view for that progress-bar in he Java file itself and put a progressbar in that view and then put that view inside the dialog.</p>
  
  <p>I want sth like this: </p>
  
  <p><img src="https://i.imgur.com/WYBMy.png" alt="Alert Dialog with ProgressBar"></p>