我试图拉出所有团队名称并将它们放在一个简单的列表中。我试过这样做
private void ParseAndDisplay(JsonValue json)
{
dynamic teamData = json["teams"];
//TextView name = FindViewById<TextView>(Resource.Id.txtName);
string[] teams;
foreach (var team in teamData)
{
var name = team["name"];
Console.Out.WriteLine("\r\n {0}", name);
teams = new string[] { name };
//TextView name = FindViewById<TextView>(Resource.Id.txtName);
//name.Text = team["name"];
ListAdapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, teams);
}
但是在我的设备上,它只显示数据中最后一个团队的名称,而在输出中则显示所有这些团队的名称。