Android Alert对话框空白白色背景

Android Alert对话框空白白色背景

问题描述:

我已经在我的应用程序中实现了BaseActivity模式,除了尝试显示警报对话框时,一切都很好。这是发生了什么Android Alert对话框空白白色背景

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); 
    } 
+0

所以你的问题是UserBaas.logoutUser()不会被调用? –

+0

不,问题是背景是空白的,即使在对话框消失后它仍然是空白的。 – Michael

+0

一次尝试相同的活动,而不是使用BaseActivity。 –

我觉得参数上下文有关的代码,你可以改变这种==> Activity.this(活动是要Activity类的名称显示对话框)

+0

没有工作 – Michael

试试这个:

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

这也没有工作 – Michael

试试这个:

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

也不工作。我不认为这个问题是对话框,而是整个用户界面如何受到影响 – Michael

+0

请问你可以发布你的完整代码,看看发生了什么? –

+0

我按照要求 – Michael

尝试这样.:

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