[英]Android - Star Rating Bar
I am using badoo Star Bar, and I have it all set up and working expect for when the method public void onFinalRating(int rating, boolean swipe) {
is called, the number of stars that I have selected doesn't stay highlighted, it goes back to the default state. 我正在使用badoo Star Bar,并且已经完成所有设置,并且可以预期当方法
public void onFinalRating(int rating, boolean swipe) {
被调用时,我选择的星星数量不会保持突出显示,它返回默认状态。 Here is the repo on git hub https://github.com/badoo/StarBar 这是git hub https://github.com/badoo/StarBar上的仓库
And my set up is exactly the same, haven't changed anything but here it is anyways, 我的设置完全一样,没有做任何更改,但无论如何都可以,
This is my layout 这是我的布局
<com.badoo.mobile.views.starbar.StarBar
android:id="@+id/starBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
And then here I implement it 然后我在这里实现
mStarBar = (StarBar)findViewById(R.id.starBar);
mStarBar.setOnRatingSliderChangeListener(new StarBar.OnRatingSliderChangeListener() {
@Override
public boolean onStartRating() {
// The user has initiated a rating by touching the StarBar. This call will
// immediately followed by a call to onPendingRating with the initial rating
// value.
Toast.makeText(DiningDetailActivity.this, "Started rating", Toast.LENGTH_SHORT).show();
return true;
}
@Override
public void onPendingRating(int rating) {
// This method will first be called when the user initiates a rating and then
// subsequently as the rating is updated (by the user swiping his finger along
// the bar).
Log.i(TAG, Integer.toString(rating) + "");
}
@Override
public void onFinalRating(int rating, boolean swipe) {
// If the rating is completed successfully onFinalRating is called with the
// final result. The swipe parameter specifies if the rating was done using
// a tap (false) or a swipe (true).
Toast.makeText(DiningDetailActivity.this, "Final rating " + rating, Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelRating() {
// Called if the user cancels the rating by swiping away from the StarBar and releasing.
}
});
So my question is how when I select lets say 4 stars to get them to say highlighted, instead of going back to the gray state? 所以我的问题是,当我选择让4个星星高亮显示而不是转回灰色状态时,该如何选择?
I have looked at the readME file and gone over his code and can't seem to find it. 我查看了readME文件,并遍历了他的代码,但似乎找不到它。
Thanks so much for the help :) 非常感谢你的帮助 :)
You need to save the ratings. 您需要保存评级。 You only show toasts.
您只显示吐司。 I dont know the methods of the library but there is probably a method for changing the active stars.
我不知道该库的方法,但可能有一种更改活动恒星的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.