【发布时间】:2012-10-10 18:56:56
【问题描述】:
我关注了很多这样的问题 1 change color of selected listview item,但没有发现任何有用的问题。
我有一个列表视图,我想要的是,所选项目必须突出显示,例如蓝色,即使在用户抬起手指后也是如此。
这是我在drawable中的row_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:state_focused="false"
android:drawable="@android:color/transparent" />
<item android:state_pressed="true" android:drawable="@color/light_sea_green" />
<item android:state_selected="true" android:drawable="@color/light_sea_green" />
</selector>
这是我正在膨胀的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/row_color">
<ImageView
android:id="@+id/imageView_game_row_face"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:src="@drawable/af025501" />
</LinearLayout>
【问题讨论】: