Rezaul
Rezaul

Reputation: 620

Android how to reset rating bar without calling setOnRatingBarChangeListener?

I am playing some tone using listview.

I want to change a rating bar value using setOnRatingBarChangeListener.

enter image description here enter image description here

changeRatingPlayer
                .setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

                    @Override
                    public void onRatingChanged(RatingBar ratingBar,
                            float rating, boolean fromUser) {
                        // TODO Auto-generated method stub
                        setToneRating();
                    }
                });

Also I want to reset rating bar after the user clicks on some other item of the list. But when I click on a item of the list and using changeRatingPlayer.setRating(0); I reset the rating bar, but in the meantime setOnRatingBarChangeListener is called again, but I don't want this.

Upvotes: 1

Views: 781

Answers (1)

Kuffs
Kuffs

Reputation: 35661

Use the fromUser parameter to determine if the rating was changed by the user or if it was changed by your code.

Upvotes: 3

Related Questions