【问题标题】:Android RatingBarAndroid 评分栏
【发布时间】:2016-02-25 08:58:56
【问题描述】:

我是安卓开发新手
我需要创建一个根据应用​​程序详细信息显示评级的 RatingBar。
我的应用程序根据用户输入计算一个值,它将显示在 RatingBar 中。
该条仅根据计算值显示值(例如 4/5 星)
我需要创建它,用户不能直接更改 RatingBar 的值。他们只输入输入并且该输入计算一些值并且该值需要显示在 RatingBar 中。

你能帮我做这件事吗?这是我能想到的使用 RatingBar 的唯一方法(据我所知)。

【问题讨论】:

标签: android ratingbar


【解决方案1】:

试试这个。我想这会解决你的问题

这是java代码

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

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"

        />

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      试试 isIndicator 属性。如果设置为 true,用户将无法通过触摸 RatingBar 来更改值。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多