android之SeekBar控件用法
2024-08-25 08:36:18
MainActivity.java
package com.example.mars_2400_seekbar; import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.os.Build; public class MainActivity extends Activity implements OnSeekBarChangeListener {
private TextView tv;
private SeekBar sb; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.textView1);
sb = (SeekBar) findViewById(R.id.seekbar);
sb.setOnSeekBarChangeListener(this);
} @Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
tv.setText("Progress is " + progress
+ (fromUser ? " Trigger" : " Nontrigger") + " by user.");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
System.out.println("onStart-->"+seekBar.getProgress());
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
System.out.println("onStop-->"+seekBar.getProgress());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }
activity_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:id="@+id/textView1"/> <SeekBar android:id="@+id/seekbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
最新文章
- libpng使用
- 递归查询树形结构的SQL
- Python的高级特性11:拓展基本数据类型(dict)
- 清北学堂2017NOIP冬令营入学测试P4747 D’s problem(d)
- 李洪强漫谈iOS开发[C语言-048]-打印平方表
- Flash Attribute
- 通过Bresenham算法实现完成矢量线性多边形向栅格数据的转化
- Shared and Exclusive Locks 共享和排它锁
- 探究adroid活动
- Windows下Python中的中文路径和中文输出问题
- messageBox以及新窗体的使用
- SQL 分组排序、CASE...WHEN...、是否为空 查询
- 一个巨low的“2048”
- leecode.147. 对无头结点链表进行插入排序
- python编码转换
- BZOJ1022[SHOI2008]小约翰的游戏——anti-SG(反尼姆博弈)
- easyui treegrid 动态展开数据(暂记)
- 第三方包源码maven 下载
- tcp/ip网络里的客户端和服务器端 信息交流 与 安全
- Tomcat8.5 升级tomcat版本导致出现异常,Base64不存在
热门文章
- caffe: compile error : undefined reference to `cv::imread(cv::String const&;, int)&#39; et al.
- Qt事件和信号的区别 .
- QQ登入(2)获取用户信息
- 非root模式下安装mysql php小记
- JavaOOP 试题
- messagepcak 资料
- 你了解System.out.println()的真正含义吗?
- [原]总结VIM的实用技巧
- JS代码实现网站设为首页加入收藏功能
- [Spring] IOC - study