dan87
dan87

Reputation: 333

Intent to a preferenceScreen

I was wondering if it is possible to intent to a specific preferenceScreen:

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="first_preferencescreen">
<CheckBoxPreference
        android:key="wifi enabled"
        android:title="WiFi" />
<PreferenceScreen
        android:key="second_preferencescreen"
        android:title="WiFi settings">
    <CheckBoxPreference
            android:key="prefer wifi"
            android:title="Prefer WiFi" />
    ... other preferences here ...
</PreferenceScreen>

I'd like to intent to "second_preferencescreen", is it possible?

Upvotes: 0

Views: 178

Answers (1)

mpkuth
mpkuth

Reputation: 7129

Split up your <PreferenceScreen> items into separate resource files. Say preferences1.xml and preferences2.xml. In general, Android xml can only have one root (top level) tag.

Then create FirstPreferenceActivity and SecondPreferencesActivity that extend PreferenceActivity.

Then call addPreferencesFromResource(R.xml.preferences1) or addPreferencesFromResource(R.xml.preferences2) in onCreate as seen here.

Once you've got that setup, then you can call startActivity(new Intent(this, FirstPreferencesActivity.class)) or startActivity(new Intent(this, SecondPreferencesActivity.class)).

Upvotes: 1

Related Questions