问题
rate = (TextView) findViewById(R.id.puan);
rb = (RatingBar) findViewById(R.id.ratingBar);
rb.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean b) {
final float numStars = ratingBar.getRating();
editor = wm.edit();
editor.putFloat("numStars", rating);
editor.commit();
float ratings = wm.getFloat("numStars", 0);
rate.setText(rating + "/" + String.valueOf(ratings));
}
});
wm = PreferenceManager.getDefaultSharedPreferences(this);
float rating = wm.getFloat("numStars", 0f);
rb.setRating(rating);
Here is my code its work fine but when i give a rate its hold it like 4.0/4.0 i want its hold it 4.0/5.0 how can i do that? Image rating bar
回答1:
A quick google search asking for Android RatingBar documentation took me to this page: https://developer.android.com/reference/android/widget/RatingBar
A quick look through the page led me to find the following info:
void setMax(int max);
//Set the upper range of the progress bar max.
void setMin(int min);
//Set the lower range of the progress bar min.
Please feel free to reply if you need any further assistance or have other questions regarding this topic.
来源:https://stackoverflow.com/questions/50193834/ratingbar-how-to