【问题标题】:Ratingbar - how to?评分栏 - 如何?
【发布时间】:2018-05-06 05:20:35
【问题描述】:
 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);

这是我的代码,它工作正常,但是当我给它一个保持它像 4.0/4.0 一样的速率时,我希望它保持它 4.0/5.0 我该怎么做? Image rating bar

【问题讨论】:

    标签: java android ratingbar


    【解决方案1】:

    通过谷歌快速搜索要求 Android RatingBar 文档将我带到此页面:https://developer.android.com/reference/android/widget/RatingBar

    快速浏览该页面后,我找到了以下信息:

    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.
    

    如果您需要任何进一步的帮助或对此主题有其他问题,请随时回复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-15
      • 1970-01-01
      相关资源
      最近更新 更多