获取百分比值从搜索栏? [英] Getting percentage value from seek bar?

查看:214
本文介绍了获取百分比值从搜索栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一样有这个数字,这是从这个获得价值,

I have just like this figure, which is get value from this,

在这里我使用搜索栏,但如果我在图何况不能得到的价值。将你们帮我这个问题?

Here I Used SeekBar,but could not get value where i mention in figure. would you guys help me this problem?

所以也请为我提供的信息,是什么让这种价值的最佳解决方案?

这里都是differenet寻求吧。

首先搜索栏有25%和第二寻求巴尔50%。如果我有滚动的搜索栏,然后同时增加或减少盒所占的百分比。

First SeekBar have 25% and second seek Baar 50%. If i have scroll seek bar then simultaneously increase or decrease the percentage in box.

推荐答案

创建XML视图

 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="100" >

    <SeekBar
        android:id="@+id/SeekBarId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="92" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginLeft="4dp"
        android:layout_weight="8"
        android:gravity="center"/>
</LinearLayout>

设置onSeekBarChageListener在搜索栏,如下所示:

set onSeekBarChageListener on the seekBar, like this:

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
                    {

                        public void onStopTrackingTouch(SeekBar bar)
                        {
                            int value = bar.getProgress(); // the value of the seekBar progress
                        }

                        public void onStartTrackingTouch(SeekBar bar)
                        {

                        }

                        public void onProgressChanged(SeekBar bar,
                                int paramInt, boolean paramBoolean)
                        {
                            textView.setText("" + paramInt + "%"); // here in textView the percent will be shown
                        }
                    });

这篇关于获取百分比值从搜索栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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