package com.pocketdigi;

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

public class main extends Activity {
/** Called when the activity is first created. */
SeekBar sb;
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.tv);
sb=(SeekBar)findViewById(R.id.seek);
sb.setProgress(90);
sb.setOnSeekBarChangeListener(sbLis);
}
private OnSeekBarChangeListener sbLis=new OnSeekBarChangeListener(){

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
//進度改變時觸發
tv.setText(String.valueOf(sb.getProgress()));

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// 開始拖動時觸發,與onProgressChanged區別在於onStartTrackingTouch在停止拖動前只觸發一次
//而onProgressChanged只要在拖動,就會重複觸發
}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//結束拖動時觸發

}

};
}

創作者介紹

Frank's Blog

Frank 發表在 痞客邦 PIXNET 留言(0) 人氣()