在透明活动上显示Dialog时,活动崩溃

时间:2016-09-29 12:46:51

标签: android dialog

在课程ActivityEditDefaultPaymentMethodBid中,我想显示Dialog,当它在Manifest android:theme设置为"@style/AppTheme.NoActionBar"时有效,但当我将其更改为"@android:style/Theme.Translucent.NoTitleBar"时,活动崩溃

您对活动崩溃有什么建议吗?如何解决这个问题?

显示对话框的代码是:

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.

1 个答案:

答案 0 :(得分: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();

}