Android 如何通过单击项目来更改listview中的颜色?
因此,在a中,我有一些任务,例如“周日下午3:00洗车”,洗车后,我想单击列表视图上的任务(项目)并更改颜色,这样我就知道我已经完成了该任务Android 如何通过单击项目来更改listview中的颜色?,android,android-listview,Android,Android Listview,因此,在a中,我有一些任务,例如“周日下午3:00洗车”,洗车后,我想单击列表视图上的任务(项目)并更改颜色,这样我就知道我已经完成了该任务 <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/nTask"
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/nTask"
android:background="#FFFFFF" >
</ListView>
Color1.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/selector_state_blue"/>
选择器_state_blue.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="270"
android:endColor="#FF91B2FF"
android:startColor="#4491B2FF" />
<corners android:radius="10px" />
</shape>
使用选择器检查这一点@Raghunandan谢谢,第二个链接看起来很有用。你能至少给我投票吗:)