How to know rating view is clicking ?
ismailtosun opened this issue · 3 comments
ismailtosun commented
In recylerview adapter
ratingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() {
@Override
public void onRatingChange(BaseRatingBar ratingBar, int rating) {
Log.e(TAG, "onRatingChange: " + rating);
holder.ratingView.setRate(4);
}
});
in this rate action I want to set new rate holder.ratingView.setRate(4);
but it's show rating value ? why ?
williamyyu commented
Hello @ismailtosun ,
I'm not sure what's your problem,
did you mean the code holder.ratingView.setRate(4);
doesn't work?
ismailtosun commented
no,I mean when I click the rateview, I want to show an alert dialog.And don't want to let rate.
What I did
ratingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() {
@Override
public void onRatingChange(BaseRatingBar ratingBar, int rating) {
//Show alert here
holder.ratingView.setRate(0);
}
});
but rating view still 1.
williamyyu commented
so you just want to show an alert and the ratingbar do nothing?
you can set the value of property app:srb_isIndicator
to true, and set a onTouchListener on ratingbar.
example:
baseRatingBar.setIsIndicator(true);
baseRatingBar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Toast.makeText(getContext(), "hi", Toast.LENGTH_SHORT).show();
}
return true;
}
});