在Activity中调用DialogFragment

时间:2014-10-10 08:00:38

标签: android

如何在DialogFragment中调用Activity,就像我在FragmentActivity中调用它一样?

以下是我FragmentActivity的示例代码:

private void showAlertDialog(int title, int message){

    AlertDialogFragment alert = AlertDialogFragment.createInstance(
            getActivity().getString(title),
            getActivity().getString(message));

    alert.show(getChildFragmentManager(), "Alert");

}

alert.show( ???, "Alert" );

1 个答案:

答案 0 :(得分:7)

如果Activity扩展FragmentActivity使用getSupportFragmentManager() 如果不使用:getFragmentManager()