我有这个类,它在每次点击后配置drawable的图像。
*******
int mProgressBar;
int mProgressBarBg;
boolean check = true;
ProgressBar progress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progress = (ProgressBar) findViewById(R.id.progressBar1);
progress.setProgress(50);
findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(check) {
mProgressBarBg = R.drawable.bg_bar_progress;
mProgressBar = R.drawable.progress_quest_green;
check = false;
} else {
mProgressBarBg = R.drawable.bg_bar_progress_orange;
mProgressBar = R.drawable.progress_quest_orange;
check = true;
}
findViewById(R.id.progressBar).setBackgroundResource(mProgressBarBg);
Drawable colorDrawable = getResources().getDrawable(mProgressBar);
Rect bounds = progress.getProgressDrawable().getBounds();
progress.setProgressDrawable(colorDrawable);
progress.getProgressDrawable().setBounds(bounds);
}
});
}
*******
问题: 点击后未显示进度。我该如何解决?
答案 0 :(得分:-1)
这可能会有所帮助:Android ProgressBar.setProgressDrawable only works once?
这个答案:
"为了我的工作,我做了你说的话并添加:mySeekBar.setProgress(mySeekBar.getProgress()+ 1); mySeekBar.setProgress(mySeekBar.getProgress() - 1);这样做我强行移动,但保持相同的位置。 - Derzu"