I have a PreferenceActivity that add PreferenceFragment via Headers:
public class SettingsActivity extends PreferenceActivity {
...
@Override
public void onBuildHeaders(List<Header> target) {
loadHeadersFromResource(R.xml.pref_headers, target);
}
...
}
Now I need to call a method of PreferenceFragment from PreferenceActivity but I can't use Fragment fragment = getFragmentManager.findFragmentByTag("tagfragment");
because using Headers to add PreferenceFragment I don't know the TAG or the ID assigned to the fragment.
How can I solve?
[SOLVED]
Solved using this method: https://stackoverflow.com/a/18005721/570488
Make sure the PreferenceActivity is already loaded when you call this:
MyPreferenceFragment should be replaced for your own PreferenceFragment class name.