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>

最新文章

  1. libpng使用
  2. 递归查询树形结构的SQL
  3. Python的高级特性11:拓展基本数据类型(dict)
  4. 清北学堂2017NOIP冬令营入学测试P4747 D’s problem(d)
  5. 李洪强漫谈iOS开发[C语言-048]-打印平方表
  6. Flash Attribute
  7. 通过Bresenham算法实现完成矢量线性多边形向栅格数据的转化
  8. Shared and Exclusive Locks 共享和排它锁
  9. 探究adroid活动
  10. Windows下Python中的中文路径和中文输出问题
  11. messageBox以及新窗体的使用
  12. SQL 分组排序、CASE...WHEN...、是否为空 查询
  13. 一个巨low的“2048”
  14. leecode.147. 对无头结点链表进行插入排序
  15. python编码转换
  16. BZOJ1022[SHOI2008]小约翰的游戏——anti-SG(反尼姆博弈)
  17. easyui treegrid 动态展开数据(暂记)
  18. 第三方包源码maven 下载
  19. tcp/ip网络里的客户端和服务器端 信息交流 与 安全
  20. Tomcat8.5 升级tomcat版本导致出现异常,Base64不存在

热门文章

  1. caffe: compile error : undefined reference to `cv::imread(cv::String const&amp;, int)&#39; et al.
  2. Qt事件和信号的区别 .
  3. QQ登入(2)获取用户信息
  4. 非root模式下安装mysql php小记
  5. JavaOOP 试题
  6. messagepcak 资料
  7. 你了解System.out.println()的真正含义吗?
  8. [原]总结VIM的实用技巧
  9. JS代码实现网站设为首页加入收藏功能
  10. [Spring] IOC - study