Change rating bar on Android

I have a rating bar in my application and I would like when I hover my mouse over it the rating will change

How can i do this? Maybe?

Best wishes

+2


a source to share


2 answers


There is no mouse in Android.



+10


a source


There is absolutely no mouse in android, but in the click event you can make changes to your rating bar.



 public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) {
    final int numStars = ratingBar.getNumStars();
    mRatingText.setText( 
            getString(R.string.app_name) + " " + rating + "/" + numStars);

    // Since this rating bar is updated to reflect any of the other rating
    // bars, we should update it to the current values.
    if (mIndicatorRatingBar.getNumStars() != numStars) {
        mIndicatorRatingBar.setNumStars(numStars);
        mSmallRatingBar.setNumStars(numStars);
    }
    if (mIndicatorRatingBar.getRating() != rating) {
        mIndicatorRatingBar.setRating(rating);
        mSmallRatingBar.setRating(rating);
    }
    final float ratingBarStepSize = ratingBar.getStepSize();
    if (mIndicatorRatingBar.getStepSize() != ratingBarStepSize) {
        mIndicatorRatingBar.setStepSize(ratingBarStepSize);
        mSmallRatingBar.setStepSize(ratingBarStepSize);
    }
}

      

+1


a source







All Articles