Ratingbar - how to?

半世苍凉 提交于 2019-12-11 16:53:49

问题


 rate = (TextView) findViewById(R.id.puan);
        rb = (RatingBar) findViewById(R.id.ratingBar);
        rb.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean b) {
                final float numStars = ratingBar.getRating();
                editor = wm.edit();
                editor.putFloat("numStars", rating);
                editor.commit();
                float ratings = wm.getFloat("numStars", 0);
                rate.setText(rating + "/" + String.valueOf(ratings));
            }
        });
        wm = PreferenceManager.getDefaultSharedPreferences(this);
        float rating = wm.getFloat("numStars", 0f);
        rb.setRating(rating);

Here is my code its work fine but when i give a rate its hold it like 4.0/4.0 i want its hold it 4.0/5.0 how can i do that? Image rating bar


回答1:


A quick google search asking for Android RatingBar documentation took me to this page: https://developer.android.com/reference/android/widget/RatingBar

A quick look through the page led me to find the following info:

void setMax(int max);
//Set the upper range of the progress bar max.

void setMin(int min);
//Set the lower range of the progress bar min.

Please feel free to reply if you need any further assistance or have other questions regarding this topic.



来源:https://stackoverflow.com/questions/50193834/ratingbar-how-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!