简体   繁体   中英

Change Rating Bar on Android

I have a ratingbar in my app, and I would like when I pass the mouse over it, the rating changes

How can I do that ? it's possible?

best regards

Android中没有鼠标。

Absolutely there is no mouse in android but on click event you can make changes in 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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM