在 main layout 中我使用:
<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" >
在 main layout 中如何使用 Categories?
你可以在 Main layout xml 中使用 categories:
<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 文件,给 catogeries 创建新的 xml。
PreferenceCategory 应该为 PreferenceActivity 使用,并且定义在 /res/xml 文件夹中。你不能在layout 的 xml 中定义。