我想创建一个进度条ProgressBar screenshot,就像给定的图像一样,星形图像应该根据时间(每秒)减少。那么,请指导我该怎么办?我正在使用倒数计时器的处理程序 timeString *我们从不同的类
获取它select salution||' '||firstname||' '||lastname as custName , city as custCity ,state as custState,zip as custZip, dob as custDob ,idhardtoken as custAdarNo from mstuser ;
答案 0 :(得分:1)
尝试以下 -
SeekBar seekBar1 = (SeekBar)findViewById(R.id.seekBar1);
drw = getResources().getDrawable(R.drawable.ic_launcher);
seekBar1.setOnSeekBarChangeListener(new yourListener());
private class yourListener implements SeekBar.OnSeekBarChangeListener {
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
iSize = 100 - progress;
tv.setText(String.valueOf(new Integer(progress)));
drw = resize(drw);
seekBar.setThumb(drw);
}
public void onStartTrackingTouch(SeekBar seekBar) {}
public void onStopTrackingTouch(SeekBar seekBar) {}
}
//Reduce size of seekbar
private Drawable resize(Drawable image) {
Bitmap b = ((BitmapDrawable)image).getBitmap();
Bitmap bitmapResized = Bitmap.createScaledBitmap(b, iSize, iSize, false);
return new BitmapDrawable(getResources(), bitmapResized);
}
答案 1 :(得分:0)
将此添加为活动的内部类或片段需要进度条减少。
class CounterClass extends CountDownTimer {
int totalDuration;
public CounterClass(long millisInFeature, long countDownInterval) {
// TODO Auto-generated constructor stub
super(millisInFeature , countDownInterval);
this.totalDuration =millisInFeature
}
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
int progress =((millisUntilFinished * 100 / totalDuration))
progressbar.setProgress(progress);
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
}
oncreate()或事件开始
(new CounterClass(30000,1000)).start();