使用以下用于示出进度对话框代码,进度对话框显示不
public void showDialog() {
try {
Log.d(TAG, "showDialog--------------");
progressDialog = new Dialog(RewardsActivity.this);
final View dialogView = LayoutInflater.from(RewardsActivity.this).inflate(R.layout.progress_dialog, null);
progressDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
progressDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
progressDialog.setContentView(dialogView);
progressDialog.setCancelable(true);
final ImageView progressSpinner = (ImageView) dialogView.findViewById(R.id.ivProgress);
final RotateAnimation anim = new RotateAnimation(0f, 350f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(500);
anim.setInterpolator(new LinearInterpolator());
progressSpinner.startAnimation(anim);
progressDialog.show();
Log.d(TAG, "showDialog--------------");
progressDialog.getWindow().setLayout(120, 120);
} catch (Exception e) {
}
}
在Activity类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rewards);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
tinyDB = new TinyDB(getApplicationContext());
showDialog();
new GetRewardsResponse(getApplicationContext(), this, tinyDB);
viewpager = (ViewPager) findViewById(R.id.viewPager);
indicator = (CircleIndicator) findViewById(R.id.indicator);
indicator.setViewPager(viewpager);
if (progressDialog.isShowing()) {
progressDialog.hide();
}
}
在调试的onCreate
调用showDialog
,执行showDaialog
方法(对话是不可见虽然)完全但当应用程序正在运行它不会执行showDialog
,因为我无法看到我的日志语句在Android显示器
尝试评论if(progressDialog.isShowing()){ progressDialog.hide(); }并检查 – kevz