Android警报对话框空白白色背景

Android警报对话框空白白色背景,android,android-alertdialog,Android,Android Alertdialog,我已经在我的应用程序中实现了BaseActivity模式,除了尝试显示警报对话框外,其他一切都很好。事情就是这样 当我试图取消对话框时,我只剩下这个 下面是显示位于基本活动中的对话框的代码: new AlertDialog.Builder(this) .setTitle("Logging out") .setMessage("Are you sure?") .setPositiveButton("

我已经在我的应用程序中实现了BaseActivity模式,除了尝试显示警报对话框外,其他一切都很好。事情就是这样

当我试图取消对话框时,我只剩下这个

下面是显示位于基本活动中的对话框的代码:

new AlertDialog.Builder(this)
                .setTitle("Logging out")
                .setMessage("Are you sure?")
                .setPositiveButton("Yes", new 

    DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            UIUtils.setAnimation(swipeRefreshLayout, true);
                            UserBaas.logoutUser();

                        }
                    })
                    .setNegativeButton("No", null)
                    .show();
这个问题在模拟器和实际设备上都会持续存在。可能是什么问题

switch (item) {
            case NAVDRAWER_ITEM_HOME:
                startActivity(new Intent(this, MainActivity.class));
                break;
            case NAVDRAWER_ITEM_MEMOS:
                intent = new Intent(this, MemoGroupActivity.class);
                intent.putExtra("section", MemoGroupActivity.MEMO);
                createBackStack(intent);
                break;
            case NAVDRAWER_ITEM_GROUPS:
                intent = new Intent(this, MemoGroupActivity.class);
                intent.putExtra("section", MemoGroupActivity.GROUP);
                createBackStack(intent);
                break;
            case NAVDRAWER_ITEM_CONNECTIONS:
                createBackStack(new Intent(this, ConnectionsActivity.class));
                break;
            case NAVDRAWER_ITEM_DOCUMENTS:
                createBackStack(new Intent(this, DocumentsActivity.class));
                break;
            case NAVDRAWER_ITEM_SETTINGS:
                createBackStack(new Intent(this, SettingsActivity.class));
                break;
            case NAVDRAWER_ITEM_LOGOUT:
                showLogoutDialog();
                break;
        }
下面是UIUtils.setAnimation()的代码


我认为参数上下文,您可以更改此==>活动。此(活动是要显示对话框的活动类的名称)

我认为参数上下文,您可以更改此==>活动。此(活动是要显示对话框的活动类的名称)

尝试以下操作:

 .setNegativeButton(Cancel, new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int id) {
        finish();
     });
试试这个:

 .setNegativeButton(Cancel, new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int id) {
        finish();
     });
试试这个:

AlertDialog.Builder b = new AlertDialog.Builder(Your_Activity_Name.this);
        b.setTitle("Logging out");
        b.setMessage("Are you sure?");

        b.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // do something
            }
        });

        b.setNegativeButton("No", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        b.create().show();
试试这个:

AlertDialog.Builder b = new AlertDialog.Builder(Your_Activity_Name.this);
        b.setTitle("Logging out");
        b.setMessage("Are you sure?");

        b.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // do something
            }
        });

        b.setNegativeButton("No", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        b.create().show();
像这样试试

.setNegativeButton(Cancel, new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int id) {
    dialog.dismiss();
 });
像这样试试

.setNegativeButton(Cancel, new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int id) {
    dialog.dismiss();
 });

因此,您的问题是UserBaas。logoutUser()未被调用?否,问题是背景为空,即使对话框消失后也会显示为空。请在同一活动中尝试一次,而不是使用BaseActivity。我尝试在子活动中实现该方法,然后从BaseActivity调用它,但当对话框显示时,该方法无效,背景中没有任何内容,正如您在解除警报时所说,您看到的是相同的背景。你所展示的警觉对话没有问题。要了解更多信息,请告诉我们您在UIUtils.setAnimation(swipeRefreshLayout,true)中正在做什么;UserBaas.logoutUser();因此,您的问题是UserBaas。logoutUser()未被调用?否,问题是背景为空,即使对话框消失后也会显示为空。请在同一活动中尝试一次,而不是使用BaseActivity。我尝试在子活动中实现该方法,然后从BaseActivity调用它,但当对话框显示时,该方法无效,背景中没有任何内容,正如您在解除警报时所说,您看到的是相同的背景。你所展示的警觉对话没有问题。要了解更多信息,请告诉我们您在UIUtils.setAnimation(swipeRefreshLayout,true)中正在做什么;UserBaas.logoutUser();那也不行。我认为问题不在于对话框,而在于整个用户界面是如何受到影响的。你能发布你的完整代码来看看发生了什么吗?我已经按照要求完成了,但也不起作用。我认为问题不在于对话框,而在于整个用户界面是如何受到影响的。你能发布完整的代码来看看发生了什么吗?我已经按照要求发布了