如何将RatingBar的stepSize从1.0更改为1?

时间:2013-04-30 09:59:20

标签: android ratingbar

在我的xml中,我设置android:stepSize="1",但是当我实现它时。它仍然显示1.0。

如何将其更改为1?

rtnCafe.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

        @Override
        public void onRatingChanged(RatingBar ratingBar, float rating,
                boolean fromUser) {
             Log.i("rating",""+rtnCafe.getRating());
             Toast.makeText(getApplicationContext(), "rating " +rtnCafe.getRating(), Toast.LENGTH_LONG).show();
             txtLove.setText(""+rtnCafe.getRating());

        }
    });

2 个答案:

答案 0 :(得分:1)

您可以将它转换为int喜欢,

txtLove.setText(""+(int)rtnCafe.getRating());

答案 1 :(得分:1)

只需在rtnCafe.getRating(...

之前添加(int)