zoukankan      html  css  js  c++  java
  • Android——拖动条SeekBar

    1、activity_seekbar.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <SeekBar
            android:id="@+id/sb"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:max="100"
            android:progress="50"
            android:secondaryProgress="75" />

        <TextView
            android:id="@+id/progressText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/trackingText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

    2、SeekBarActivity.java

    public class SeekBarActivity extends Activity implements
            OnSeekBarChangeListener {
        // 声明相关View对象
        private SeekBar sb;
        private TextView progressText, trackingText;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_seekbar);
            // 取得View相关对象
            sb = (SeekBar) findViewById(R.id.sb);
            progressText = (TextView) findViewById(R.id.progressText);
            trackingText = (TextView) findViewById(R.id.trackingText);
            // *************
            sb.setOnSeekBarChangeListener(this);

        }

        // 在拖动中,即值在改变
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromTouch) {
            progressText.setText("当前值为:" + progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
            trackingText.setText("正在调节!");
        }

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {
            trackingText.setText("停止调节");
        }

    }

  • 相关阅读:
    footer在最低显示
    jQuery toast message 地址 使用
    linux 获取经过N层Nginx转发的访问来源真实IP
    Java Json格式的字符串转变对象
    多个机器获取微信access-token导致的有效性问题
    站点技术---301重定向
    C++技术问题总结-第8篇 STL内存池是怎么实现的
    IIS中遇到无法预览的问题(HTTP 错误 401.3
    梯度下降深入浅出
    COM-IE-(2)
  • 原文地址:https://www.cnblogs.com/Defry/p/4412991.html
Copyright © 2011-2022 走看看