zoukankan      html  css  js  c++  java
  • 控件:拖动条 SeekBar(事件处理)

    View Code
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation
    ="vertical"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="fill_parent">
    <SeekBar
    android:id="@+id/seekbar"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="wrap_content" />
    <TextView
    android:id="@+id/text"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="wrap_content"/>
    </LinearLayout>
    View Code
    import android.app.Activity;
    import android.os.Bundle;
    import android.text.method.ScrollingMovementMethod;
    import android.widget.SeekBar;
    import android.widget.TextView;

    public class MySeekBarDemo extends Activity {
    private SeekBar seekbar = null;
    private TextView text = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setContentView(R.layout.main);
    // 取得组件
    this.seekbar = (SeekBar) super.findViewById(R.id.seekbar);
    // 取得组件
    this.text = (TextView) super.findViewById(R.id.text);
    // 文本组件的内容可以滚动
    this.text.setMovementMethod(ScrollingMovementMethod.getInstance());
    this.seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListenerImpl());
    }

    private class OnSeekBarChangeListenerImpl implements SeekBar.OnSeekBarChangeListener {
    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    MySeekBarDemo.this.text.append("*** 开始拖动,当前值:"
    + seekBar.getProgress() + "\n");
    }
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress,
    boolean fromUser) {
    MySeekBarDemo.this.text.append("*** 正在拖动,当前值:"
    + seekBar.getProgress() + "\n");
    }
    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
    MySeekBarDemo.this.text.append("*** 停止拖动,当前值:"
    + seekBar.getProgress() + "\n");
    }

    }
    }



  • 相关阅读:
    前端工程师如何打发闲余时光?(转)
    比较好的前端开发工具
    蓝桥历年套题 约数倍数选卡片 博弈
    单调栈求全1(或全0)子矩阵的个数 洛谷P5300与或和 P3400仓鼠窝
    5-15
    2018CCPC桂林站G Greatest Common Divisor
    STL中的BITSET运用
    2018CCPC桂林站JStone Game
    牛客2019湘潭大学程序竞赛
    Combine String HDU
  • 原文地址:https://www.cnblogs.com/androidsj/p/2379150.html
Copyright © 2011-2022 走看看