Search code examples
androidtextviewratingbar

Android RatingBar TextView


how can you create a textview that reacts to the ratingbar stars, for example if a user rate 1 star I want my text view to like say "Your rating is kinda low please leave us some feedback", How do you do this?


Solution

  • Attach a rating listener to your rating bar and check the current rating on the bar, if the condition hits... do what you want:

        ratingbar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                float rating=ratingBar.getRating();
                if(rating<2){
                  //do your thing
    
                }
    
            }
        });