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 に 1 つの xml フォルダーを作成し、カテゴリ用に新しい xml を作成します。

于 2012-09-28T09:39:56.740 に答える
0

PreferenceCategoryfor を使用することになっており、 /res/xmlフォルダーPreferenceActivity内で定義されています。レイアウトのxmlで定義できないと思います。

于 2012-09-28T09:43:38.447 に答える