繁体   English   中英

Android-星级栏

[英]Android - Star Rating Bar

我正在使用badoo Star Bar,并且已经完成所有设置,并且可以预期当方法public void onFinalRating(int rating, boolean swipe) {被调用时,我选择的星星数量不会保持突出显示,它返回默认状态。 这是git hub https://github.com/badoo/StarBar上的仓库

我的设置完全一样,没有做任何更改,但无论如何都可以,

这是我的布局

 <com.badoo.mobile.views.starbar.StarBar
    android:id="@+id/starBar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" />

然后我在这里实现

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

所以我的问题是,当我选择让4个星星高亮显示而不是转回灰色状态时,该如何选择?

我查看了readME文件,并遍历了他的代码,但似乎找不到它。

非常感谢你的帮助 :)

您需要保存评级。 您只显示吐司。 我不知道该库的方法,但可能有一种更改活动恒星的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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