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("停止调节");
        }

    }

  • 相关阅读:
    java中super构造方法的理解
    js和jquery
    hdfs数据导入及spark导入hdfs数据
    mysql设置定时任务
    ssh 设置无密登陆
    实验九 堆排序
    实验8 Hash表的建立和查找
    实验七 图的最小生成树算法
    实验六 huffman树的实现及应用
    实验五 二叉树的建立、遍历及应用
  • 原文地址:https://www.cnblogs.com/Defry/p/4412991.html
Copyright © 2011-2022 走看看