2016-07-29 35 views
1

我已經在我的應用程序中實現了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。 –

回答

0

我覺得參數上下文有關的代碼,你可以改變這種==> Activity.this(活動是要Activity類的名稱顯示對話框)

+0

沒有工作 – Michael

0

試試這個:

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

這也沒有工作 – Michael

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

也不工作。我不認爲這個問題是對話框,而是整個用戶界面如何受到影響 – Michael

+0

請問你可以發佈你的完整代碼,看看發生了什麼? –

+0

我按照要求 – Michael

0

嘗試這樣.:

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