当我在PreferenceFragment中点击一个Preference时,我正试图调出一个DialogFragment.不幸的是,当我在DialogFragment.show()中调用getFragmentManager()时,我收到以下错误:
Cannot resolve method ‘show(android.app.FragmentManager,java.lang.String)’
问题是我似乎无法从这个片段中引用android.support.v4.app.FragmentManager.负责这个片段的活动从FragmentActivity延伸,但显然这还不够.我也试过调用getSupportFragmentManager(),但这给了我这个错误:
Cannot resolve method ‘getSupportFragmentManager()’
我怎样才能做到这一点?
这是一些代码:
gPrefAcknowledgements.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { DialogAcknowledgements dialogAck = new DialogAcknowledgements(); dialogAck.show(getFragmentManager(),"acknowledgements"); return true; } });