简体   繁体   中英

ListPreference not showing by clicking on preference screen

Nothing happens when I clicking the ListPreference on Preference screen. No entries are shown to select. (I'm testing on Android 4.4)

Preference xml:

<PreferenceCategory
        android:title="Image"
        android:key="image">
    <ListPreference
                android:title="Flash"
                android:key="flash"
                android:defaultValue="Off"
                android:entries="@array/flash"
                android:entryValues="@array/flash_values"
                android:persistent="true"/>
    </PreferenceCategory>

Array values xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="opts">
        <item>auto</item>
        <item>50</item>
        <item>100</item>
        <item>200</item>
        <item>400</item>
        <item>800</item>
    </string-array>

    <string-array name="opts_values">
        <item>auto</item>
        <item>50</item>
        <item>100</item>
        <item>200</item>
        <item>400</item>
        <item>800</item>
    </string-array>

    <string-array name="flash">
        <item>Auto</item>
        <item>On</item>
        <item>Off</item>
    </string-array>

    <string-array name="flash_values">
        <item>0</item>
        <item>1</item>
        <item>2</item>
    </string-array>
</resources>

Title is correctly shown but nothing happens on clicking the preference. No error while building. Preference List is not shown as dialog. All other types are working correctly.

Edit:

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

    <PreferenceCategory
        android:title="Image"
        android:key="image">

        <SwitchPreference
            android:title="Video Mode"
            android:key="video"
            android:defaultValue="false"/>

        <ListPreference
            android:title="Flash"
            android:key="flash"
            android:defaultValue="Off"
            android:entries="@array/flash"
            android:entryValues="@array/flash_values"
            android:persistent="true"/>

        <SwitchPreference
            android:title="PNG"
            android:key="png"
            android:defaultValue="false"
            android:summary="Image format in PNG"
            android:enabled="false"/>

        <ListPreference
            android:title="Iso"
            android:key="iso"
            android:summary="set iso value"
            android:entries="@array/opts"
            android:entryValues="@array/opts_values"
            android:enabled="true"
            android:persistent="true"
            android:defaultValue="auto"/>

        </PreferenceCategory>

</PreferenceScreen>

根据我的评论-检查您的首选项活动,以确保您没有任何代码可以覆盖默认行为(即,您的首选项有一个监听器,该监听器正在窃取touch事件)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM