我有一个对话框,当我首先调用它时一切正常,但是当我第二次调用时,我得到以下输出:“试图调用虚拟方法'android.content.res.Resources $ Theme android.content.Context.getTheme( )”上的空对象引用”
这是我的代码
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
dialog.setContentView(R.layout.dialog_metka_aims);
dialog.setCancelable(true);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.show();
dialog.getWindow().setAttributes(lp);