进度条和进度框
进度条
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100" />
//注册一个拖动变化的监听器
seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
//停止拖动调用的方法
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
Log.i(TAG,"当前进度:"+progress);
Editor editor = sp.edit();
editor.putInt("progress", progress);
editor.commit();
}
//开始拖动调用的方法
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
//在拖动的过程中调用的方法
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
}
});
seekbar = (SeekBar) findViewById(R.id.seekBar1);
seekbar.setProgress(progress);
进度框弹框
// 进度条对话框
public void click05(View view) {
final ProgressDialog pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);//水平显示
pd.setMax(100);
pd.setTitle("提醒");
pd.setMessage("正在加载数据...请稍后");
pd.show();
new Thread() {
public void run() {
for (int i = 0; i <= 100; i++) {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
pd.setProgress(i);//设置进度
}
pd.dismiss();//关闭
};
}.start();
}