How to set rating bar to minimum one star?

Chandru picture Chandru · Oct 14, 2014 · Viewed 9.5k times · Source

I have a requirement to rate for a user with minimum of one star and after that ratings should increase to 0.5. But my question is that the user should not change the minimum rating of star to 0.5 or 0. 1 should be the default rating. Please help with this and awaiting for your earlier response. I also tried implementing by listeners from the link but completely struct with the logic inside My code is:

ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

    @Override public void onRatingChanged(RatingBar ratingBar, float rating, 
      boolean fromUser) {

    }
});

Answer

Nooh picture Nooh · Oct 14, 2014
 ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

@Override public void onRatingChanged(RatingBar ratingBar, float rating, 
  boolean fromUser) {
     if(rating<1.0f)
          ratingBar.setRating(1.0f);
}
});