Android Activity as a dialog

后端 未结 10 2394
轮回少年
轮回少年 2020-11-22 02:31

I have an Activity named whereActity which has child dialogs as well. Now, I want to display this activity as a dialog for another activity.

How can I d

10条回答
  •  爱一瞬间的悲伤
    2020-11-22 03:15

    If your activity is being rendered as a dialog, simply add a button to your activity's xml,

    Then attach a click listener in your Activity's Java code. In the listener, simply call finish()

    Button close_button = (Button) findViewById(R.id.close_button);
    close_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    

    That should dismiss your dialog, returning you to the calling activity.

提交回复
热议问题