Android-Show Custom Dialog

后端 未结 6 1720
忘了有多久
忘了有多久 2021-01-24 20:15

In my android application, I am using a custom dialog. When I try to show the dialog, it causes an error. I don\'t know what I am doing wrong, and I am really confused.

<
6条回答
  •  余生分开走
    2021-01-24 20:25

    Try this code

     protected Dialog onCreateDialog(int id) {
      Dialog dialog;
      switch(id) {
       case 0:
        dialog = new Dialog(this);
    
        dialog.setContentView(R.layout.paused);
        dialog.setTitle("Game Paused");
        dialog.show();
        break;
    default:
        dialog = null;
    }
    return null;
    

    }

    I just replaced dialog = new Dialog(getApplicationContext()) to dialog = new Dialog(this);

提交回复
热议问题