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

时间:2016-07-29 02:39:36

标签: android android-alertdialog

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

enter image description here

当我尝试取消对话框时,我就离开了。

enter image description here

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

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()

的代码
public static void setAnimation(SwipeRefreshLayout swipeRefreshLayout, boolean value) {
        swipeRefreshLayout.setEnabled(value);
        swipeRefreshLayout.setRefreshing(value);
    }

4 个答案:

答案 0 :(得分:0)

我认为参数Context,你可以改变这个==> Activity.this(Activity是要显示对话框的Activity类的名称)

答案 1 :(得分:0)

试试这个:

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

答案 2 :(得分:0)

试试这个:

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

答案 3 :(得分:0)

试试这样。:

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