Ratingbar sending value to Textview android

Asked

Viewed 316 times

-1

Good afternoon, How I pass the value of a Ratingbar to a direct Textview without using clicks?

  • 2

    Can explain better?

2 answers

1

TextView textView = (TextView) findViewById(R.id.textView);
RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);   
ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
    @Override
    public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
        textView.setText(String.valueOf(rating));
    }
});

0

You can use the call:

ratingBar.getRating();

But this value is a Float, then just convert to String or use as Float.

  • Would it be possible to block the value from being changed without having to pass enable=false? So the user can only see the value.

  • I usually put the direct value in xml: android:rating="4"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.