1

在主布局中我想使用类似的东西

<PreferenceCategory
        android:summary="@string/menu_language_settings"
        android:title="@string/menu_language_settings" >

但在这里我只有

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:paddingTop="50dp" >

如何在主布局中使用类别?这在主布局中甚至可能吗?

4

2 回答 2

0

是的,您可以在主布局 xml 中使用类别,如以下示例 xml 代码:-

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory android:title="@string/audio_quality" android:key="audio_quality">

       <EditTextPreference android:title="@string/echo_cancellation_tail"   android:key="echo_cancellation_tail" android:summary="@string/echo_cancellation_tail_desc" android:defaultValue="200" android:numeric="signed" /> 

       <ListPreference android:title="@string/echo_mode" android:key="echo_mode" android:summary="@string/echo_mode_desc" android:defaultValue="2" android:entryValues="@array/echo_mode_values" android:entries="@array/echo_mode_choices" /> 

     </PreferenceCategory>
</PreferenceScreen>

否则在 res 中创建一个 xml 文件夹并为类别创建新的 xml

于 2012-09-28T09:39:56.740 回答
0

PreferenceCategory应该用于PreferenceActivity并在/res/xml文件夹中定义。我认为您不能在布局的 xml 中定义它。

于 2012-09-28T09:43:38.447 回答