Search code examples
androidratingbar

How to change stepSize of RatingBar from 1.0 to 1?


In my xml I set android:stepSize="1" but when I implement it. It still show 1.0.

how to change it to 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());

        }
    });

Solution

  • You can just cast it to int like,

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