我有这样的DialogFragment:
public class GallerySinglePictureDialogFragment extends BasicDialogFragment {
private Dialog mDialog;
private Bitmap image;
public GallerySinglePictureDialogFragment() {
}
public GallerySinglePictureDialogFragment(Bitmap image) {
this.image = image;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mDialog = new Dialog(getActivity(), R.style.Theme_GallerySinglePictureDialog);
mDialog.setContentView(R.layout.frag_gallery_single_picture);
((ImageViewTouch)mDialog.findViewById(R.id.image_viewer)).setImageBitmap(image);
return mDialog;
}
@Override
public void onStop() {
super.onStop();
if(getDialog() != null){
getDialog().dismiss();
}
}
}
一切正常,除了一件事 - 当我旋转屏幕时,我的对话框片段中的位图消失了。当然,这是因为空的类构造函数。但我不知道如何修复这个错误。