离散搜索栏的Andr​​oid应用程序? [英] Discrete seekbar in Android app?

查看:121
本文介绍了离散搜索栏的Andr​​oid应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个搜索栏的Andr​​oid应用程序,允许用户选择-5和5之间的值(它映射到强烈不同意和非常同意)。如何使离散值的搜索栏?或者有更好的UI控件,我可以用呢?

i would like to create a seekbar for an Android app that allows the user to select a value between -5 and 5 (which maps to "strongly disagree" and "strongly agree"). how do i make a seekbar with discrete values? or is there a better UI widget i could use for this?

感谢。

推荐答案

搜索栏的离散值的伟大工程。我们使用搜索栏进行离散数据,如下图所示。要显示选择哪个项目,我们只是改变所选文本视图的字体,因此较大。您也可以通过更改背景颜色或东西突出。它的工作原理pretty的好。您将要调用SETMAX(11)上的搜索栏,然后在你的code,你需要(-5〜5)适当的范围内(0〜11)之间进行转换。

The Seekbar works great for discrete values. We use a Seekbar for discrete data as shown below. To show which item is selected, we just change the font of the selected text view so it is bigger. You could also highlight by changing the background color or something. It works pretty well. You will want to call setMax(11) on the seek bar, and then in your code you need to translate between the range (0 through 11) and (-5 through 5) appropriately.

 <LinearLayout 
           android:orientation="vertical"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:gravity="center_horizontal">
     <LinearLayout 
           android:orientation="horizontal"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:gravity="center_horizontal">
    <TextView android:text="-5"
            android:id="@+id/answerNegative5"
            android:textSize="25sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    <TextView android:text="-4"
            android:id="@+id/answerNegative4"
            android:textSize="25sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    <TextView android:text="-3"
            android:id="@+id/answerNegative3"
            android:textSize="25sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    .....
  </LinearLayout>

  <SeekBar android:id="@+id/intensitySlider"
                    android:layout_weight="0"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" />
</LinearLayout>

这篇关于离散搜索栏的Andr​​oid应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆