java - Setting android rating bar to nearest half stars from float variable -


i have looked around solution this, find answer set actual numbers not variables.

i rating bar display same number of stars score out of 5 going in 0.5s, is possible 3.5 etc. can set individual float values rating bar, cannot use variable same thing, rounds nearest integer.

the code using follows:

    ratingbar bar=(ratingbar)findviewbyid(r.id.ratingbar1);      bar.setnumstars(5);     bar.setstepsize(0.5f);     bundle b = getintent().getextras();     int score= b.getint("score");     //change score out of ten star rating out of 5             float scores = score / 2;     //display star rating     bar.setrating(scores); 

any received. thanks.

score needs set float, not int. int rounded, thing need change float score = b.getint("score")l


Comments