我在更改颜色或progressDialog时遇到问题。我已经看到了很多变更示例,但没有满足我的需求,这是我的代码,需要您的帮助:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_DOWNLOAD_PROGRESS:
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage(getApplicationContext().getString(R.string.download));
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setProgressDrawable(new ColorDrawable(android.graphics.Color.BLUE)); // my bad test
mProgressDialog.setCancelable(true);
mProgressDialog.show();
return mProgressDialog;
default:
return null;
}
}
最佳答案
覆盖ProgressDialog的onCreate
方法,并对其进度栏进行任何更改。
ProgressDialog mProgress = new ProgressDialog(this){
@Override
protected void onCreate(android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Now we retrive this dialog ProgressBar
ProgresBar bar = (ProgressBar) findViewById(android.R.id.progress);
//Do what you want with it here
};
};