有没有办法清除ListView中的选定项目?清除SingleChoice ListView选择
的ListView的定义是这样的:
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minHeight="50dp"
android:id="@+id/example_list"
android:layout_weight="2"
android:choiceMode="singleChoice"/>
和使用自定义适配器被填充。
选定的项目使用选择强调:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<gradient
android:startColor="#3E5260"
android:endColor="#3E5260"
android:angle="270" />
</shape>
</item>
<item android:state_activated="true">
<shape>
<gradient
android:startColor="#3E5260"
android:endColor="#3E5260"
android:angle="270" />
</shape>
</item>
</selector>
现在我真的是在一个单一的活动2名列表视图,当一个产品在一个ListView中选择
我要取消选择项另一个ListView。
两个列表视图提高项目被点击以下处理:
void DeviceList_Click(object sender, EventArgs e)
{
//easy enough to check which ListView raised the event
//but then I need to deselect the selected item in the other listview
}
我已经试过了诸如:
exampleList.SetItemChecked(exampleList.SelectedItemPosition, false);
和
exampleList.SetSelection(-1);
但是,这似乎并没有上班。
这似乎工作,没有试过那个,谢谢 – TimothyP 2013-03-04 01:43:00
什么是=>符号?我从来没有见过在android代码中使用过。 – 2014-06-30 21:53:12
@IgorGanapolsky这是一个lambda表达式,一个匿名方法。这是C#。在Java中,您有'IOnClickListener'实现。 – Cheesebaron 2014-07-01 08:40:54