Instead of using a nested PreferenceScreen, we can use a simple Clickable Preference and make it work as if it were a "nested header"; this will show a regular ActionBar as it launches an instance of PreferenceActivity and therefore will also support a single panel / double panel navigation style. Here's a simplified simplified code example that includes customizing the BackBar navigation button:
main_preferences.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:orderingFromXml="true"> <Preference android:key="a_preference" /> <Preference android:key="subscreen_preference" /> <Preference android:key="another_ preference" /> </PreferenceSreen>
subscreen_preference.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:orderingFromXml="true"> <Preference android:key="sub_preference" /> </PreferenceSreen>
MyPreferenceActivity.class
public class MyPreferenceActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
It is important . If you use Proguard, be sure to add the following rule, otherwise isInvalidFragment () will return false:
-keepnames class com.foo.MyPreferenceActivity$SubscreenFragment
source share