通过学习seekBar变动进度条,总结使用步骤如下:
1、首先在layout目录下创建一个main.xml布局文件:
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="测试SeekBar"
/>
<SeekBar
android:id="@+id/seekbarId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

</LinearLayout>
2、创建一个类MainActivity继承Activity:
package com.seekbar;

import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;

public class MainActivity extends Activity {
private SeekBar seekBar = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
seekBar = (SeekBar)findViewById(R.id.seekbarId) ;
//设置该进度条的最大值
seekBar.setMax(100);
//绑定监听seekBar
seekBar.setOnSeekBarChangeListener(new SeekBarListener());
}
//定义一个监听器,该监听器负责监听进度条状态的改变
private class SeekBarListener implements SeekBar.OnSeekBarChangeListener{
//当进度条的进度发生变化时,会调用该方法
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
System.out.println(progress);
}
//当用户开始滑动滑块时,调用该方法,只调一次
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
System.out.println("start--->" + seekBar.getProgress());
}
//当用户结束对滑块的滑动时,调用该方法,只调一次

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
System.out.println("stop--->" + seekBar.getProgress());
}

}
}

更多相关文章

  1. android 恢复出厂设置流程
  2. 【android】Android(安卓)7.0适配步骤
  3. Android(安卓)Studio 中build.gradle文件的详细解析
  4. Mac Android(安卓)Studio快捷键
  5. Android(安卓)AIDL详解
  6. Fragment的交互及管理
  7. android实时高斯模糊
  8. [Android(安卓)Pro] 关于BitmapFactory.decodeStream(is)方法无
  9. Android(安卓)利用服务Service创建标题栏通知

随机推荐

  1. mysql 5.7.16 ZIP包安装配置教程
  2. mysql 5.6.37(zip)下载安装配置图文教程
  3. mysql 8.0.15 版本安装教程 连接Navicat.
  4. 基于Windows安装MySQL 8.0.12图文教程
  5. windows10更换mysql8.0.17详细教程
  6. 详解Mysql 30条军规
  7. 浅谈MySQL分页Limit的性能问题
  8. ubuntu安装mysql数据库方法
  9. mysql允许外网访问以及修改mysql账号密码
  10. mysql 8.0 错误The server requested aut