Is there a way to clear the selected item in a ListView?
The ListView is defined like this:
<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"/>
And is filled using a custom Adapter.
The selected item is highlighted using a Selector:
<?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>
Now what I really have is 2 ListViews in a single activity and when an item is
selected in one ListView I want to deselect the item in the other ListView.
Both ListViews raise the following handler when an item is clicked:
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
}
I've tried things like:
exampleList.SetItemChecked(exampleList.SelectedItemPosition, false);
and
exampleList.SetSelection(-1);
But that does not seem to work.