2
如何在Activity
中調用DialogFragment
與我在FragmentActivity
中調用它的方式相同?在活動中調用DialogFragment
這裏是我的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");
我已經嘗試過一個,但我收到一個錯誤在運行時,因爲我試圖擴展活動,而不是我猜測的FragmentActivity。任何關於@ user974801的想法? – ENN 2014-10-10 08:23:55
'getSupportFragmentManager()'如果您使用'FragmentActivity'。 – EpicPandaForce 2014-10-10 08:37:16
getFragmentManager()需要最小API級別11 – 2016-07-22 10:14:35