SeekBar 拖动条

来源:互联网 发布:提额神器软件 编辑:程序博客网 时间:2024/06/05 06:09

转载请注明出处http://blog.csdn.net/mr_leixiansheng/article/details/64125076



<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">    <SeekBar        android:id="@+id/seek_bar"        android:progress="50"        android:max="100"        android:layout_width="match_parent"        android:layout_height="wrap_content" />    <TextView        android:id="@+id/tv1"        android:layout_width="match_parent"        android:layout_height="wrap_content" />    <TextView        android:id="@+id/tv2"        android:layout_width="match_parent"        android:layout_height="wrap_content" /></LinearLayout>


package com.example.leixiansheng.myseekbar;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.SeekBar;import android.widget.TextView;public class MainActivity extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener{    private SeekBar seekBar;    private TextView textView_1;    private TextView textView_2;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        seekBar = (SeekBar) findViewById(R.id.seek_bar);        textView_1 = (TextView) findViewById(R.id.tv1);        textView_2 = (TextView) findViewById(R.id.tv2);        seekBar.setOnSeekBarChangeListener(this);    }    @Override    public void onProgressChanged(SeekBar seekBar, int i, boolean b) {        textView_1.setText("正在拖动");        textView_2.setText("当前值是:" + i);    }    @Override    public void onStartTrackingTouch(SeekBar seekBar) {        textView_1.setText("开始拖动");    }    @Override    public void onStopTrackingTouch(SeekBar seekBar) {        textView_1.setText("停止拖动");    }}



0 0
原创粉丝点击