android之SeekBar控件用法
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>
android之SeekBar控件用法的更多相关文章
- Android的Spinner控件用法解析
微调框 微调框提供一种方法,让用户可以从值集中快速选择一个值.默认状态下,微调框显示其当前所选的值. 触摸微调框可显示下拉菜单,其中列有所有其他可用值,用户可从中选择一个新值. 您可以使用 Spinn ...
- android之Spinner控件用法
用法1: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...
- android之RatingBar控件用法
MainActivity.java package com.example.mars_2500_ratingbar; import android.support.v7.app.ActionBarAc ...
- android之AutoCompleteTextView控件用法
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...
- android之datepicker控件用法
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Android笔记---常用控件以及用法
这篇文章主要记录下Android的常用控件以及使用的方法,Android 给我们提供了大量的UI控件,合理地使用这些控件就可以非常轻松地编写出相当不错的界面,这些是Android学习的基础,没有什么业 ...
- Android 中常见控件的介绍和使用
1 TextView文本框 1.1 TextView类的结构 TextView 是用于显示字符串的组件,对于用户来说就是屏幕中一块用于显示文本的区域.TextView类的层次关系如下: java.la ...
- [Android] Android 卡片式控件CardView的优雅使用
[Android] Android 卡片式控件CardView的优雅使用 CardView是在安卓5.0提出的卡片式控件 其具体用法如下: 1.在app/build.gradle 文件中添加 comp ...
- Android Material Design控件学习(三)——使用TextInputLayout实现酷市场登录效果
前言 前两次,我们学习了 Android Material Design控件学习(一)--TabLayout的用法 Android Material Design控件学习(二)--Navigation ...
随机推荐
- UIview 学习与自定义--ios
UIView *view1=[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; view1.backgroundColor=[UI ...
- Object-c 语言
字符串操作: http://www.myexception.cn/mobile/455287.html 1,判断两字符串是否相同 NSString *str1 = @"hello pepe& ...
- unity,下面两个协程不等价
//代码1 IEnumerator A(){ Debug.Log(“hi1”); { yield return new WaitForSeconds(1f); Debug.Log(“hi2”); } ...
- js 动态 activex 组件
function writeObject(){ var obj = document.getElementById("mydelphi"); if(!obj){ var divob ...
- js移动焦点到最后
当输入框(input/textarea)获得焦点时,将焦点移动到最后,在某些情况下用户体验很好.网上的大部分方法都是针对IE浏览器的.代码如下: var el = document.getElem ...
- python函数: 内置函数
forthttp://blog.csdn.net/pipisorry/article/details/44755423 Python内置函数 Python内置(built-in)函数随着python解 ...
- jQuery 追加元素的方法如append、prepend、before
1.jQuery append() 方法 jQuery append() 方法在被选元素的结尾插入内容. 实例 复制代码代码如下: $("p").append("Some ...
- HDP2.4安装(一):Centos7安装
在进入大数据领域来,一直使用微软的Azure HDInsight,当前在中国区仅支持在Windows系统上部署集群,虽然创建的过程很简单,但对于开发人员来说,就是一个黑盒子,在更深入的研究和开发扩展的 ...
- 06文件与IO
这节主要学习系统调用stat.lstat.fstat. 格式如下: int fstat(int filedes, struct stat *buf); int stat(const char *pat ...
- web api 500 错误
改了API 方法内容后,就直接F5运行起来. 客户端用WebClient请求,老是返回500错误. 无意中重新编译了WEIAPI项目,客户端就正常了.