在Android上更改评级栏

时间:2010-04-14 10:35:54

标签: java android

我的应用中有一个评级栏,我希望当我将鼠标移过它时,评分会发生变化

我该怎么做?这是可能的?

最好的问候

2 个答案:

答案 0 :(得分:10)

Android中没有鼠标。

答案 1 :(得分:1)

绝对没有鼠标在Android中,但在点击事件中,您可以在评级栏中进行更改。

 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);
    }
}