Java Listview项的渐变不会更改ontapping
我有一个使用自定义数组适配器的listview设置,列表看起来很好,我使用了渐变和每个项目的背景,也出现了,但代码还声明在点击时更改渐变,下面没有出现的是我的xml main.xml row_list.xml list_selector.xml ogbg.xml//normal background gradient ogpress.xml//gradient可在轻敲时更改Java Listview项的渐变不会更改ontapping,java,android,listview,gradient,Java,Android,Listview,Gradient,我有一个使用自定义数组适配器的listview设置,列表看起来很好,我使用了渐变和每个项目的背景,也出现了,但代码还声明在点击时更改渐变,下面没有出现的是我的xml main.xml row_list.xml list_selector.xml ogbg.xml//normal background gradient ogpress.xml//gradient可在轻敲时更改 我过去也有过类似的问题。尝试切换选择器项目的顺序,我不知道为什么,但选择器的行为取决于项目的顺序。如果这不起作用,请尝试
我过去也有过类似的问题。尝试切换选择器项目的顺序,我不知道为什么,但选择器的行为取决于项目的顺序。如果这不起作用,请尝试取消选中并按的关联。为每个州做一个额外的项目
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:dividerHeight="0.1dp"
android:listSelector="@drawable/list_selector"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/txtListText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="20dp"
android:textSize="35sp"
android:textColor="#545454"
android:background="@drawable/ogbg"
/>
</LinearLayout>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Selector style for listrow -->
<item
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/ogbg" />
<item android:state_pressed="true"
android:drawable="@drawable/ogpress" />
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/ogpress" />
</selector>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FFFAFAFA"
android:centerColor="#FFFFFFFF"
android:endColor="#FFFFFFFF"
android:angle="90"/>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FF05c1ff"
android:endColor="#7F05c1ff"
android:angle="90"/>
</shape>