I'm trying to display a RatingBar View that is only capable of showing a one star rating, or no stars. This seems so trivial...
My ratingbar is defined like so:
My view implements OnRatingBarChangeListener and OnTouchListener
My OnRatingBarChange handler has no code. My OnTouch handler looks like so:
@Override
public boolean onTouch(View v, MotionEvent event)
{
if(event.getAction() == MotionEvent.ACTION_DOWN)
{
if(this.mRating.getRating() == 0)
{
this.mRating.setRating(1);
}
else
{
this.mRating.setRating(0);
}
return true;
}
return false;
}
No matter what, the onTouch event does not succeed at setting the rating back to zero. This seems way too trivial. What am I doing wrong?
Thanks!
Consider using ToggleButton
and btn_star
stock drawable instead. Here's example:
<ToggleButton
android:button="@android:drawable/btn_star"
android:background="@android:color/transparent"
android:textOn=""
android:textOff=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With