【发布时间】:2010-03-05 11:03:00
【问题描述】:
我有一个带有自定义 item_row.xml 的列表视图。我以这种方式定义了一个选择器:
<?xml version="1.0" encoding="utf-8"?>
<item
android:state_pressed="false"
android:drawable="@drawable/list_bg" >
</item>
<item
android:state_pressed="true"
android:drawable="@drawable/header_bg" >
</item>
<item
android:state_focused="false"
android:drawable="@drawable/list_bg" >
</item>
<item
android:state_focused="true"
android:drawable="@drawable/header_bg">
</item>
然后这样放入item_row.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:orientation="vertical"
android:background="@drawable/list_selector">
我想要两件事:
- 当我用箭头键移动时,选中的项目改变了它的背景。它适用于选择器的实际实现。
- 当我按下一个项目时,该项目的背景也发生了变化,但它不适用于实际的选择器。
有什么想法吗?我也尝试设置到 ListView android:listSelector="@drawable/list_selector" 但它也不起作用。
谢谢
【问题讨论】: