seekBar 的用法
来源:互联网 发布:移动刷流量软件 编辑:程序博客网 时间:2024/06/05 18:26
< 大家可以粘贴代码进自己的Androidstudio观看 图片不好显示 >
SeekBar :允许用户拖动滑块来改变值,因此通常用于对系统的某种数值进行调节,比如音量。
、、布局:添加一个SeekBar拖动条;再添加一个TextView文本来显示拖动条进度。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" tools:context="com.example.administrator.myapplication.MainActivity"> <SeekBar android:id="@+id/seekBar2" android:layout_width="match_parent" android:layout_height="wrap_content"
android:max="800"
/> <TextView android:id="@+id/tv_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_gravity="center_horizontal" /></LinearLayout>
、、将拖动滑块以图标形式呈现
、、添加监听事件:实现拖动滑块计数
package com.example.administrator.myapplication;import android.support.annotation.IdRes;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.SeekBar;import android.widget.TextView;public class MainActivity extends AppCompatActivity { SeekBar myseekBar; TextView seekBarView; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); seekBarView=(TextView)findViewById(R.id.tv_text_view); myseekBar=(SeekBar)findViewById(R.id.seekBar2); myseekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { seekBarView.setText(String.valueOf(progress)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); }}
阅读全文
0 0
- seekbar 的用法
- android seekbar的用法
- seekBar 的用法
- 拖动条SeekBar的功能和用法
- android中seekbar的一点用法
- SeekBar(拖动条)-SeekBar基本用法
- 第29章:拖动条SeekBar的用法
- SeekBar(拖动条)的简单功能和用法
- <SeekBar>拖动条的 简单功能与用法
- <SeekBar>拖动条的 简单功能与用法
- 关于Android中seekbar中progressDrawable属性的用法
- Android中ToggleButton,Switch,SeekBar,RatingBar的一些用法
- SeekBar用法
- SeekBar的使用和竖向的SeekBar
- 【SeekBar】Android 自定义漂亮的SeekBar样式
- 竖直的seekbar
- SeekBar的基本使用方法
- SeekBar 的自定义样式
- SSM整合Activiti工作流
- Java中private、protected、public和default的区别
- 编程题目
- Android OpenGl ES2.0编程_相关概念与绘制顶点
- 统计字符的个数
- seekBar 的用法
- sublime Text 3 emmet自定义HTML模板
- 机器学习理论(学习笔记)
- BeanUtils.copyProperties()用法
- bzoj1116 [POI2008]CLO(记录带环连通块)
- 死锁的条件
- linux下基本操作记录mongodb
- OpenCv基础知识梳理总结
- Echarts加载自定义地图geoJson