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?
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))
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.