本文介绍了通过preferenceActivity选项启动其他preferenceScreen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了许多选项的配置菜单,我想在主$ 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>

(这是从)

这篇关于通过preferenceActivity选项启动其他preferenceScreen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 14:08