我四处寻找解决方案,但只能找到将其设置为实际数字而不是变量的答案。
我希望评级栏显示与 0.5 秒内 5 分中的分数相同的星数,因此可以获得 3.5 等。我可以为评级栏设置单独的浮点值,但不能使用对于同一件事的变量,它只是将其四舍五入到最接近的整数。
我正在使用的代码如下:
RatingBar bar=(RatingBar)findViewById(R.id.ratingBar1);
bar.setNumStars(5);
bar.setStepSize(0.5f);
Bundle b = getIntent().getExtras();
int score= b.getInt("score");
//change the score out of ten to star rating out of 5
float scores = score / 2;
//display star rating
bar.setRating(scores);
将收到任何帮助。谢谢。