我想将ListView ClickListener添加到ListView,但我不知道怎么做? 这是我创建适配器的代码的结尾:
//Get all the values from Name, and convert it to an Array
string[] NamesArray = coins.Select(c => c.Name).ToArray();
//Fill the DataSource of the ListView with the Array of Names
ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, NamesArray);
//Bind DataSource to ListView
ListviewCoinNames.Adapter = adapter;
答案 0 :(得分:1)
添加ItemClick处理程序
ListviewCoinNames.ItemClick += ListviewCoinNames_ItemClick;
然后定义它
void ListviewCoinNames_ItemClick(Object sender, AdapterView.ItemClickEventArgs e)
{
Console.WriteLine(mItems[e.Position]);
}
答案 1 :(得分:0)