通过preferenceActivity选项启动其他preferenceScreen选项、preferenceActivity、preferenceScreen

由网友(作茧自缚)分享简介:我写了许多选项的配置菜单,我想在主$ P $添加pferenceScreen可以发动其他preferenceScreen的选项。I'm writing a configuration menu with many options and I'd like to add in the main PreferenceSc...

我写了许多选项的配置菜单,我想在主$ P $添加pferenceScreen可以发动其他preferenceScreen的选项。

I'm writing a configuration menu with many options and I'd like to add in the main PreferenceScreen an option that can launch an other PreferenceScreen.

我无法弄清楚如何创建一个通用的菜单项(因此,也不EditText上preference也不复选框preference等)

I can't figure out how to create a generic menu entry (so, nor EditTextPreference nor CheckBoxPreference etc.)

感谢所有。

推荐答案

拼图你的 preferenceScreen 元素。内 preferenceScreen 将举行第二屏幕上的内容;你把内 preferenceScreen 标题和描述将是你的通用的菜单项。

Nest your PreferenceScreen elements. The inner PreferenceScreen will hold the contents of the second screen; the title and description you put on the inner PreferenceScreen will be your "generic menu entry".

例如:

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory android:title="Simple Preferences">
        <CheckBoxPreference
            android:key="checkbox"
            android:title="Checkbox Preference"
            android:summary="Check it on, check it off"
        />
        <RingtonePreference
            android:key="ringtone"
            android:title="Ringtone Preference"
            android:showDefault="true"
            android:showSilent="true"
            android:summary="Pick a tone, any tone"
        />
    </PreferenceCategory>
    <PreferenceCategory android:title="Detail Screens">
        <PreferenceScreen
            android:key="detail"
            android:title="Detail Screen"
            android:summary="Additional preferences held in another page">
            <CheckBoxPreference
                android:key="checkbox2"
                android:title="Another Checkbox"
                android:summary="On. Off. It really doesn't matter."
            />
        </PreferenceScreen>
    </PreferenceCategory>
    <PreferenceCategory android:title="Other Preferences">
        <EditTextPreference
            android:key="text"
            android:title="Text Entry Dialog"
            android:summary="Click to pop up a field for entry"
            android:dialogTitle="Enter something useful"
        />
        <ListPreference
            android:key="list"
            android:title="Selection Dialog"
            android:summary="Click to pop up a list to choose from"
            android:entries="@array/cities"
            android:entryValues="@array/airport_codes"
            android:dialogTitle="Choose a Pennsylvania city" />
    </PreferenceCategory>
</PreferenceScreen>

(这是从此示例项目)

阅读全文

相关推荐

最新文章