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つのリストビューで、アイテムが1つのリストビューで選択した
あるとき、私は内の項目の選択を解除したいです他の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
=>表記法とは何ですか?私はアンドロイドコードで使用されていることは見たことがありません。 –
@IgorGanapolskyラムダ式で、匿名メソッドです。これはC#です。 Javaでは 'IOnClickListener'の実装があります。 – Cheesebaron