作为ProgressDialog的活动

时间:2012-05-10 12:58:16

标签: android android-layout

enter image description here我要求将活动作为对话框(非警告对话框,而不是进度对话框)。此活动中没有ui组件,因为此活动执行服务器交互,基于服务器响应启动下一个活动。此活动只需显示带取消按钮的进度对话框。现在的问题是,在显示进度对话框之前启动此活动时,一小段黑色rectanagle在一秒钟或更长时间内可见,同样当此活动完成时,这是可见的。如何摆脱这个?或者有没有更好的方法将进度对话作为活动? -Thanks&问候, 馒头

@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();
}

1 个答案:

答案 0 :(得分:0)

Creating Global Dialog中,我使用了一个带有对话框的透明活动。我想你可以做同样的事情。我不记得面对你所面临的问题,而且效果很好。

Check it out