getFragmentManager()返回null,与android.support.v4.app.DialogFragment支持libraray [英] getFragmentManager() returns null, with android.support.v4.app.DialogFragment support libraray
本文介绍了getFragmentManager()返回null,与android.support.v4.app.DialogFragment支持libraray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是片段的对话框:
import android.support.v4.app.DialogFragment;
public static class SensorMeasurmentsDialogFragment extends DialogFragment {
public static SensorMeasurmentsDialogFragment newInstance(int title) {
SensorMeasurmentsDialogFragment frag = new SensorMeasurmentsDialogFragment();
Bundle args = new Bundle();
args.putInt("title", title);
frag.setArguments(args);
return frag;
@Override public Dialog onCreateDialog(Bundle savedInstanceState) {
.....
}
}
}
它的呼叫从一个普通的活动不是从fragmentActivity因为做
我的活动已经扩展mapActivity。
the call to it is done from a regular activity not from a fragmentActivity because my activity already extends mapActivity.
m_measurmentDlg=SensorMeasurmentsDialogFragment.newInstance(R.string.app_name);
m_measurmentDlg.show(m_measurmentDlg.getFragmentManager(),"measurments");
任何想法为什么是空?
any idea why is it Null?
推荐答案
活动必须从FragmentActivity延长你能够使用片段。你可能有目前使用一种变通方法,直到谷歌更新其地图图书馆。
The activity must extend from FragmentActivity for you to be able to use Fragments. You might have to use a workaround at the moment until Google updates their map library.
您可能需要使用修改后的兼容性LIB像这样的:
You might have to use a modified compatibility lib such as this one:
https://github.com/petedoyle/android-support-v4-googlemaps
这篇关于getFragmentManager()返回null,与android.support.v4.app.DialogFragment支持libraray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文