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>


 

你可能感兴趣的:(android,layout,null,Class,encoding)