我创建了一个带有足球俱乐部的ListView。我想选择一个项目,并打开一个包含所选项目信息的新活动。
这是我的ListView:
base.OnCreate (bundle);
clubs = new string[] {
"AC Milan",
"Borussia Dortmund",
"Chelsea London",
"FC Barcelona",
"Manchester United",
"Manchester City",
"Real Madrid"
};
ListAdapter = new ArrayAdapter<String> (this, Android.Resource.Layout.SimpleListItem1, clubs);
}
答案 0 :(得分:1)
答案 1 :(得分:1)
您需要覆盖OnListItemClick
才能从ListView获取所选项目:
protected override void OnListItemClick(ListView listview,
View view, int pos, long id)
{
var selectedvalue = clubs[pos];
// start new Activity here....
var intent = new Intent(this, typeof(Your_Next_Activity));
intent.PutExtra("selectedvalue", selectedvalue);
StartActivity(intent);
}