I try to display a RatingBar in a AlertDialog (It is regularly called from a Handler).

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.

Can anyone help ?

```
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();
}

```

Thanks a lot for any help !