我需要在列表视图行中设置备用颜色,但是当我这样做时,它会删除/禁用焦点默认黄色背景
我尝试使用 backgroundColor rowView.setBackgroundColor(SOME COLOR);
还带有 backgrounddrwable。
rowView.setBackgroundColor(R.drawable.view_odd_row_bg);
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_window_focused="false"
android:drawable="@color/odd" />
<!--
Even though these two point to the same resource, have two states
so the drawable will invalidate itself when coming out of pressed
state.
-->
<item
android:state_focused="true"
android:state_enabled="false"
android:state_pressed="true"
android:drawable="@color/highlight" />
<item
android:state_focused="true"
android:state_enabled="false"
android:drawable="@color/highlight" />
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@color/highlight" />
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@color/highlight" />
<item
android:state_focused="true"
android:drawable="@color/highlight" />
</selector>
但它不会工作。
有什么方法可以同时设置背景颜色和焦点颜色,这将起作用。