如何从ListView接收已检查的项目?

时间:2016-10-09 17:06:50

标签: c# android listview xamarin.android

我有一个List<>个项目,这些项目存储在ListView CheckBox&#39}中。我需要的是将检查的项目存储到另一个List<>。以下是ListView如何显示和填充数据的代码:

        List<Product> _productsList = ProductsFromXml();

        List<Product> checkedProducts = new List<Product>();

        productsListView = FindViewById<ListView>(Resource.Id.listView1);
        productsListView.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItemMultipleChoice, _productsList);
        productsListView.ChoiceMode = ChoiceMode.Multiple;

1 个答案:

答案 0 :(得分:-1)

确定。以下是c#代码:

foreach (ListViewItem xitem in productsListView.CheckedItems)
{
     // Do whatever you want with checked item 'xitem'
}