简体   繁体   English

Android RatingBar

[英]Android RatingBar

I'm new to android development 我是android开发的新手
I need to create a RatingBar that shows rating according to Application details . 我需要创建一个RatingBar来根据“应用程序详细信息”显示评分。
My App calculate a value according to user input and it will be shown in RatingBar . 我的应用程序根据用户输入计算一个值,该值将显示在RatingBar中。
That bar only shows the value (eg. 4/5 stars ) according to the calculated value 该条仅根据计算出的值显示该值(例如4/5星)
I need to create it that users can't change RatingBar's value directly .They only enter the input and that input calculate some value and that value need to be displayed in RatingBar. 我需要创建它以使用户不能直接更改RatingBar的值。他们只能输入输入,而该输入会计算一些值,并且该值需要显示在RatingBar中。

Can you please help me to do this? 你能帮我做到这一点吗? This is the only way than I can think of using RatingBar (according to my knowledge). 这是我无法想到的使用RatingBar的唯一方法(据我所知)。

Try this out.I think this will solve your problem 试试看。我认为这可以解决您的问题

This is java code 这是java代码

RatingBar ratingBar = (RatingBar)findViewById(R.id.ratingBar1);
ratingBar.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

XML code XML代码

<RatingBar

         android:id="@+id/ratingBar1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" 
         android:numStars="5"
         android:progress="30"
         android:clickable="false"     
         android:focusableInTouchMode="false"    
         android:focusable="false"

        />

如果需要限制用户手动更改等级栏,则需要在等级栏实例上应用onTouchListener并返回true

Try isIndicator attribute. 尝试isIndicator属性。 If you set true, users won't be able to change the value by touching the RatingBar. 如果设置为true,则用户将无法通过触摸RatingBar来更改值。

<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:isIndicator="true" />

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

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