项目不会显示在ListPreference中

时间:2014-06-18 20:57:52

标签: android listpreference

我尝试将dialogLayout提供给preference.xml以更改背景。 背景已更改,但对话框中没有项目。 (如果不提供此选项我有物品,但背景为白色) enter image description here

这是我的preference.xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

    <PreferenceCategory>
        <ListPreference
            android:defaultValue="10.0"
            android:dialogLayout="@layout/dialig_layout"
            android:dialogTitle="@string/sensitivity_setting_title"
            android:entries="@array/sensitivity_preference"
            android:entryValues="@array/sensitivity_preference_values"
            android:key="sensitivity"
            android:summary="@string/sensitivity_setting_details"
            android:title="@string/sensitivity_setting" />
    </PreferenceCategory>

</PreferenceScreen>

和布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/bg"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:paddingRight="?android:attr/scrollbarSize" >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="6dip"
        android:layout_marginLeft="15dip"
        android:layout_marginRight="6dip"
        android:layout_marginTop="6dip"
        android:layout_weight="1" >

        <TextView
            android:id="@+android:id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:singleLine="true"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>

    <!-- Preference should place its actual preference widget here. -->

    <LinearLayout
        android:id="@+android:id/widget_frame"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center_vertical"
        android:orientation="vertical" >

        <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            android:drawSelectorOnTop="false"
            android:scrollbarAlwaysDrawVerticalTrack="true" />
    </LinearLayout>

</LinearLayout>

我的原因是什么问题?

编辑:

<string-array name="sensitivity_preference">
    <item>@string/extra_high</item>
    <item>@string/very_high</item>
    <item>@string/high</item>
    <item>@string/higher</item>
    <item>@string/medium</item>
    <item>@string/lower</item>
    <item>@string/low</item>
    <item>@string/very_low</item>
    <item>@string/extra_low</item>
</string-array>

<string-array name="sensitivity_preference_values">
    <item>1.9753</item>
    <item>2.9630</item>
    <item>4.4444</item><!-- 10 * 1.5^(-2) -->
    <item>6.6667</item><!-- 10 * 1.5^(-1) -->
    <item>10.0</item>
    <item>15.0</item><!--     10 * 1.5      -->
    <item>22.5</item><!--   10 * 1.5^2    -->
    <item>33.75</item>
    <item>50.625</item>
</string-array>

0 个答案:

没有答案