title: RatingBar in a AlertDialog : How to change the number of stars programmatically?
body: <p>I try to display a RatingBar in a AlertDialog (It is regularly called from a Handler).</p>
  
  <p>My problem is that I can't change the number of stars. I know there is a lot of answers ot there, but always passing through the xml, which I don't want.</p>
  
  <p>Can anyone help ?</p>
  
  <pre><code>public void taskRatingPopup() {
      final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
      final RatingBar rating = new RatingBar(this);
      rating.setMax(5);
      rating.setNumStars(5);
      rating.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  
  
      popDialog.setIcon(android.R.drawable.btn_star_big_on);
      popDialog.setTitle("BlaBla");
      popDialog.setView(rating);
  
      // Button OK
      popDialog.setPositiveButton(android.R.string.ok,
      new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
  
      writeRatingFile(rating.getProgress());
  
      //Remove the dialog
      dialog.dismiss();
      }
  
      })
  
      // Button Cancel
      .setNegativeButton("Cancel",
      new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
      dialog.cancel();
      }
      });
  
      popDialog.create();
      popDialog.show();
  }
  </code></pre>
  
  <p>Thanks a lot for any help !</p>