【发布时间】:2016-06-14 09:48:23
【问题描述】:
我有一个从AppCompatDialogFragment 延伸的class
public class SendLetterDialogFragment extends AppCompatDialogFragment {
public static SendLetterDialogFragment newInstance() {
Bundle args = new Bundle();
SendLetterDialogFragment fragment = new SendLetterDialogFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.send_letter_dialog_fragment, container, false);
ButterKnife.bind(this, view);
return view;
}
}
当我从Activity(使用`getSupportFragmentManager)显示它时,它可以工作。但是我不能在 Fragment 中使用这个方法:
SendLetterDialogFragment fragment = SendLetterDialogFragment.newInstance();
fragment.show(getFragmentManager(), "lol");
我已经阅读了一些类似的相关问题 Error showing support.v7.AppCompatDialogFragment using show() method 但他们没有帮助我。
如何从Fragment 显示AppCompatDialogFragment?
附:片段放置的活动扩展AppComtapActivity。
调用 getChildFragmentManager 而不是 getFragmentManager 没有帮助。
编辑
我没有解决这个问题,所以我决定用AlertDialog.Builder创建对话框。
【问题讨论】:
标签: android android-fragments appcompatdialogfragment