简体   繁体   中英

Selecting subcategories using ListActivity of PreferenceActivity

I am using PreferenceActivity to save some default values.

I have an array that contains the list of Regions and each region SubArray that contains list of different areas. My Preference List item contains list of all regions but How can I make the listPrefernce show another ListPreference on click so it will list its subAreas?

It sounds like you want to use a subscreen described at http://developer.android.com/guide/topics/ui/settings.html#Subscreens

<PreferenceScreen  xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- opens a subscreen of settings -->
    <PreferenceScreen
        android:key="region1"
        android:title="Region 1"
        android:persistent="false">

        <ListPreference
            android:key="subarray1"
            android:title="SubArray 1" ... />

        <ListPreference
            android:key="subarray2"
            android:title="SubArray 2" ... />
        ....

    </PreferenceScreen>

    <!-- opens another subscreen of settings -->
    <PreferenceScreen
        android:key="region2"
        android:title="Region 2"
        android:persistent="false">

        <ListPreference
            android:key="subarray1"
            android:title="SubArray 1" ... />

        <ListPreference
            android:key="subarray2"
            android:title="SubArray 2" ... />
            ...

    </PreferenceScreen>
    ...
</PreferenceScreen>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM