2016-09-29 96 views
-1

顯示對話框在ActivityEditDefaultPaymentMethodBid我想顯示對話框,而當清單android:theme設置爲"@style/AppTheme.NoActionBar"它的工作原理,但是當我將其更改爲"@android:style/Theme.Translucent.NoTitleBar",活動崩潰類。活動crashesh而透明的活動

你有什麼建議爲什麼活動崩潰?如何解決這個問題?

代碼顯示對話框是:

private void showOKCancelAlertMsg(String title,String msg) { 
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ActivityEditDefaultPaymentMethodBid.this); 

    dialogBuilder.setPositiveButton(getString(R.string.txt_yes), new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int which) { 
      //(...) 
     } 
    }); 

    dialogBuilder.setNegativeButton(getString(R.string.txt_no), new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int which) 
     { 
     dialog.dismiss(); 
     } 
    }); 

    dialogBuilder.setTitle(title); 
    dialogBuilder.setMessage(msg); 
    dialogBuilder.show(); 
} 

錯誤日誌(我沒有發現任何有用這裏)

09-29 14:41:07.492 2831-2831/? D/AndroidRuntime: Shutting down VM 
09-29 14:41:07.566 1537-1583/system_process W/InputDispatcher: channel '105008b com.app.appname/com.app.appname.ActivityMain (server)' ~ Consumer closed input channel or an error occurred. events=0x9 
09-29 14:41:07.566 1537-1583/system_process E/InputDispatcher: channel '105008b com.app.appname/com.app.appname.ActivityMain (server)' ~ Channel is unrecoverably broken and will be disposed! 
09-29 14:41:07.567 1537-1583/system_process W/InputDispatcher: channel '476d20c com.app.appname/com.app.appname.ActivityComment (server)' ~ Consumer closed input channel or an error occurred. events=0x9 
09-29 14:41:07.567 1537-1583/system_process E/InputDispatcher: channel '476d20c com.app.appname/com.app.appname.ActivityComment (server)' ~ Channel is unrecoverably broken and will be disposed! 
09-29 14:41:07.567 1537-1881/system_process I/WindowState: WIN DEATH: Window{476d20c u0 com.app.appname/com.app.appname.ActivityComment} 
09-29 14:41:07.567 1537-1881/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel '476d20c com.app.appname/com.app.appname.ActivityComment (server)' 
09-29 14:41:07.570 1537-1668/system_process D/GraphicsStats: Buffer count: 2 
09-29 14:41:07.578 1537-1549/system_process I/WindowState: WIN DEATH: Window{36a0c0d u0 com.app.appname/com.app.appname.ActivityBid} 
09-29 14:41:07.581 1537-1548/system_process I/WindowState: WIN DEATH: Window{ffbb0d4 u0 com.app.appname/com.app.appname.ActivityEditDefaultPaymentMethodBid} 
09-29 14:41:07.590 1246-1246/? I/Zygote: Process 2831 exited due to signal (11) 
09-29 14:41:07.592 1537-1883/system_process I/ActivityManager: Process com.app.appname (pid 2831) has died 
09-29 14:41:07.593 1537-1883/system_process W/ActivityManager: Force removing ActivityRecord{afb1a28 u0 com.app.appname/.ActivityEditDefaultPaymentMethodBid t452}: app died, no saved state 
09-29 14:41:07.601 1537-1989/system_process I/WindowState: WIN DEATH: Window{105008b u0 com.app.appname/com.app.appname.ActivityMain} 
09-29 14:41:07.601 1537-1989/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel '105008b com.app.appname/com.app.appname.ActivityMain (server)' 
09-29 14:41:07.611 2898-2898/com.app.appname I/art: Not late-enabling -Xcheck:jni (already on) 
09-29 14:41:07.615 1537-1883/system_process I/ActivityManager: Start proc 2898:com.app.appname/u0a64 for activity com.app.appname/.ActivityBid 
09-29 14:41:07.663 2898-2903/com.app.appname I/art: Debugger is no longer active 
09-29 14:41:07.839 2898-2898/com.app.appname W/System: ClassLoader referenced unknown path: /data/app/com.app.appname-1/lib/x86_64 
09-29 14:41:07.864 2898-2898/com.app.appname I/InstantRun: Instant Run Runtime started. Android package is com.app.appname, real application class is com.app.appname.MyApplication. 

回答

0

請嘗試像 和活動主題自定義視圖 - android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar"

public void displayNotification(String name) { 

    final Dialog dialog = new Dialog(PopupActivity.this); 
    dialog.setContentView(R.layout.customnotification); 
    dialog.setTitle("Title"); 
    // set the custom dialog components - text, image and button 
    final TextView txtname = (TextView) dialog.findViewById(R.id.txtname); 
    final TextView txtnumber = (TextView) dialog 
      .findViewById(R.id.txtnumber); 

    txtnumber.setText(number); 
    txtname.setText(name); 

    Button btclose = (Button) dialog.findViewById(R.id.btclose); 
    // if button is clicked, close the custom dialog 
    btclose.setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      dialog.dismiss(); 
     } 
    }); 

    dialog.show(); 

}