SeeKBarTest

 
package com.hyz;

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

public class SeekBarJsd extends Activity {
	  
	 private SeekBar seekBar = null;
	 
	 /** Called when the activity is first created. */
	   
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.main);
	        
	        seekBar = (SeekBar) findViewById(R.id.seekBarId);
	        //设置该进度条的最大值,默认情况下为O
	        seekBar.setMax(100);
	        seekBar.setProgress(10);
	        seekBar.setOnSeekBarChangeListener(seekBarListener);
	    }	    
	    /**
	     * SeekBarListener 
	     * 定义一个监听器,该监听器负责监听进度条进度的改变
	     */
 private SeekBar.OnSeekBarChangeListener seekBarListener = new SeekBar.OnSeekBarChangeListener() {
	  	     /**
	      * 当用户结束对滑块滑动时,调用该方法
	      */
	  public void onStopTrackingTouch(SeekBar seekBar) {
	   // TODO Auto-generated method stub
	   System.out.println("stop: > "+seekBar.getProgress());
	  }
	  
	  /**
	   * 当用户开始滑动滑块时调用该方法
	   */
	  public void onStartTrackingTouch(SeekBar seekBar) {
	   // TODO Auto-generated method stub
	   System.out.println("start: => "+seekBar.getProgress());
	  }	  
	  /**
	   * 当进度条发生变化时调用该方法
	   */
	  public void onProgressChanged(SeekBar seekBar, int progress,
	    boolean fromUser) {
	   // TODO Auto-generated method stub
	   System.out.println("Changed: => "+progress);
	  }
};
}


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="@string/hello"
    />
    <SeekBar
     android:id="@+id/seekBarId"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     />
</LinearLayout>


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值