I'm trying to show a PreferenceFragment
after I select the Preferences option in my ActionBar.
However, after replacing current content with the PreferenceFragment
you can see the old content below it. As in, you can see straight through the preferences.
Am I missing something here? I used an example from a book I own, which didn't use any layout files for the preferences. Do you need those?
Used code:
Actionbar menu
private boolean MenuChoice(MenuItem item) {
switch (item.getItemId()) {
case 0:
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
ReaderPreferences prefs = new ReaderPreferences();
fragmentTransaction.replace(android.R.id.content, prefs);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
return true;
}
return false;
}
PreferenceReader
public class ReaderPreferences extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// --load the preferences from an XML file---
addPreferencesFromResource(R.xml.preference);
}
}
Actual result:
As you can see, you look straight through my preferences. What did I do wrong?