Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Naugat rating count is wrong in OnRatingBarChangeListener #14

Closed
nieldeokar opened this issue Jun 3, 2017 · 4 comments
Closed
Assignees
Labels

Comments

@nieldeokar
Copy link

nieldeokar commented Jun 3, 2017

Android version : 7.0
Lib Version : compile 'me.zhanghai.android.materialratingbar:library:1.0.2'

The callback method is giving wrong rating count. When i am clicking 1 star count is coming as 2. This is happening with each star.

Rating is 1.000000 : fromUser true
Rating is 2.000000 : fromUser true
Rating is 4.000000 : fromUser true
Rating is 5.000000 : fromUser true
Rating is 3.000000 : fromUser true

If i click on the first half of the star Rating count is proper. If i click on second half then it adds +1 to count and sets it in UI.

Activity :

 ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
      @Override
      public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {

        Log.i(TAG,String.format("Rating is %f : fromUser %b",rating,fromUser));

        mTextView.setText(String.format("Rating is %f ",rating));

      }
    });

XML :

<me.zhanghai.android.materialratingbar.MaterialRatingBar
      android:id="@+id/ratingBar2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:isIndicator="false"
      android:stepSize="1"
      android:rating="5"
     
  />
@nieldeokar nieldeokar changed the title Android Naugat rating count is not proper Android Naugat rating count is wrong in OnRatingBarChangeListener Jun 3, 2017
@zhanghai
Copy link
Owner

zhanghai commented Jun 3, 2017

Maybe you need android:stepSize="1". See framework RatingBar source.

@zhanghai zhanghai self-assigned this Jun 3, 2017
@nieldeokar
Copy link
Author

@DreaminginCodeZH : problem still persists even after using android:stepSize. I have updated with all params which i am using.

@zhanghai
Copy link
Owner

zhanghai commented Jun 3, 2017

Is this problem library-specifc? If you replace all MaterialRatingBar with Framework RatingBar, does the problem still persist? If so, then it's a general Android issue more suitable for StackOverflow.

@nieldeokar
Copy link
Author

nieldeokar commented Jun 3, 2017 via email

@zhanghai zhanghai closed this as completed Jun 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants