Yog*_*esh 1 android listview colors alternate
我需要在列表视图行中设置备用颜色,但是当我这样做时,它会删除/禁用焦点默认的黄色背景
我尝试使用backgroundColor rowView.setBackgroundColor(SOME COLOR);
还有backgrounddrwable.
Run Code Online (Sandbox Code Playgroud)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>
Run Code Online (Sandbox Code Playgroud)
但它不会工作.
我们有什么办法可以同时设置背景颜色和焦点颜色.
我发现本教程对我很有帮助.
我能够使ListView项目具有交替的颜色加上焦点项目保持默认的突出显示颜色.
| 归档时间: |
|
| 查看次数: |
12456 次 |
| 最近记录: |