我需要将活动作为对话框(不是警报对话框,而是进度对话框)。此活动中没有 ui 组件,因为此活动进行服务器交互,根据服务器响应启动下一个活动。此活动中只需要显示一个带有取消按钮的进度对话框。现在的问题是,在显示进度对话框之前启动此活动时,一个小的黑色矩形可见一秒钟或更长时间,当此活动完成时,它也是可见的。如何摆脱这个?或者有没有更好的方式让进度对话框作为活动?-谢谢和问候,曼朱
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityAsDialogActivity.this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
String str ="Hellow World";
txtView = (TextView)findViewById(R.id.txtview);
this.setFinishOnTouchOutside(false);
txtView.setText(R.string.select_dialog);
ActivityAsDialogActivity.this.setTitle(R.string.app_name);
mProgressHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (mProgress >= MAX_PROGRESS) {
mProgressDialog.dismiss();
Intent intent = new Intent(ActivityAsDialogActivity.this, ActivityOne.class);
startActivity(intent);
finish();
} else {
mProgress++;
mProgressDialog.incrementProgressBy(1);
mProgressHandler.sendEmptyMessageDelayed(0, 100);
}
}
};//end of handler
showDialog(DIALOG_PROGRESS);
mProgressDialog.setProgress(0);
mProgressHandler.sendEmptyMessage(0);
}//end of onCreate()
@Override
public void onBackPressed(){
Log.d("Manju ==>"," back key pressed");
finish();
}
@Override
public void finish(){
Log.d("Manju ==>", " inside finish()");
super.finish();
}