Im在全屏中显示DialogFragment中存在一些问题。在我的应用程序中,我有一个片段,当你点击某个按钮时,它会调用一个DialogFragment。但DialogFragment只是填充片段的区域(在操作栏下方)。我想它填写所有这样的屏幕:http://img845.imageshack.us/img845/8682/myimage2.pngAndroid中的全屏DialogFragment(通过ActionBar)
任何帮助吗?
public class ItensActivity extends Fragment {
...
public void openDialogItens()
{
dialog = new ItemDialog();
dialog.show(getFragmentManager(), "");
getFragmentManager().executePendingTransactions();
}
public static class ItemDialog extends DialogFragment
{
@SuppressWarnings("deprecation")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(getContentView());
Dialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(true);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.FILL_PARENT;
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setAttributes(lp);
return dialog;
}
private View getContentView() {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.popup_item, null);
return view;
}
}
我不确定我是否理解你想要的,但是如果你想要一个“全屏”片段,为什么要使用DialogFragment?改用普通的碎片。 – TomTasche 2013-04-27 16:24:31
这是因为我想显示它像一个弹出/对话框,显示它的背后是什么,类似的:http://i.stack.imgur.com/uV5Jd.png。但DialogFragment没有覆盖操作栏 – 2013-04-27 16:34:42
所以...你不想要一个* fullscreen *对话框,而是一个部分覆盖你的ActionBar的对话框,对吧? – TomTasche 2013-04-27 16:35:59