微调并不适用dropDownSelector属性并不、属性、适用、dropDownSelector

2023-09-13 01:03:08 作者:足够惹人迷

我使用的是微调,并希望添加微调 - 改变行为取决于国家(重点,pressed)

I'm using spinner and want to add spinner - to change behavior depends of states(focused, pressed)

示例项目在这里 https://github.com/vovs/spinner_issue

我的code:

activity_main.xml

<Spinner
        android:id="@+id/spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:spinnerMode="dropdown"
        android:dropDownSelector="@drawable/spinner_state" />

spinner_state.xml

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_enabled="false"
        android:drawable="@color/black" />
    <item
        android:state_pressed="true"
        android:state_enabled="true"
        android:drawable="@color/red" />
    <item
        android:state_focused="true"
        android:state_enabled="true"
        android:drawable="@color/red" />
    <item
        android:state_enabled="true"
        android:drawable="@color/gray" />
</selector>

AndroidManifest:

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

所以,如果我在模拟器的Andr​​oid 4.0.2 API 14上运行的应用程序,并尽量选择一些项目或滚动使用我的鼠标滚轮没有任何影响,我在选择设置(当preSS或滚动 - 项目应是红色的,但它是蓝色 - 默认为ICS颜色)

So, if I run app in emulator Android 4.0.2 API 14 and try to select some item or scroll using wheel of my mouse no any effect, that I set in selector(when press or scrolling - items should be red, but it is blue - default for ICS color).

有关Android 2.2的API 8时preSS或使用滚轮滚动(在这种情况下,国家的重点)的颜色是黄色[橙](默认颜色为Android 2.2)

For Android 2.2 API 8 when press or scroll using wheel(in this case state is focused) color is yellow[orange](default color for Android 2.2)

如何启用选择的微调?

推荐答案

还有一个官方的bug ... https://$c$c.google.com/p/android/issues/detail?id=24922

also an official bug... https://code.google.com/p/android/issues/detail?id=24922

什么帮助:

<resources>
    <style name="Theme.MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:dropDownListViewStyle">@style/Theme.MyListView</item>
    </style>

    <style name="Theme.MyListView" parent="@android:style/Widget.Holo.Light.ListView">
        <item name="android:listSelector">@drawable/orange_list</item>
    </style>
</resources>

祝你好运!