6

如何在 Android 中将 contentDescription 添加到 ListPreference。contentDescription 必须在列表中使用

我的偏好布局中有几次 ListPreference 看起来像这样

  <ListPreference
        android:entries="@array/entries"
        android:entryValues="@array/entryValues"
        android:key="keylist_1"
        android:title="@string/setting"
        android:layout="@layout/custom_checkbox_preference" />

每个都使用相同的布局。布局 custom_checkbox_preference 如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <TextView
            android:id="@+android:id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"            
            android:singleLine="true" />

        <TextView
            android:id="@+android:id/summary"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/title" />
    </RelativeLayout>

</LinearLayout>

我需要添加到标题内容描述如何访问它?

我尝试添加到 ListPreference:

        android:hint="@string/desc_setting"
        android:contentDescription="@string/desc_setting"

但这不起作用。我也无法将其添加到标题文本视图中的 custom_checkbox_preference 中,因为它已被其他 ListPreferences 使用。

4

0 回答 0