简体   繁体   English

Ratingbar-如何?

[英]Ratingbar - how to?

 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? 这是我的代码,它的工作正常,但是当我给它一个速率保持它像4.0 / 4.0时,我想要它保持它4.0 / 5.0,我该怎么办呢? Image rating bar 图片等级栏

A quick google search asking for Android RatingBar documentation took me to this page: https://developer.android.com/reference/android/widget/RatingBar 快速的Google搜索询问Android RatingBar文档将我带到了此页面: 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. 如果您需要任何进一步的帮助或对此主题有其他疑问,请随时回复。

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

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