0

到目前为止,我已经创建了一个列表视图,它显示了数组中的项目。但是,我不知道如何使这些项目执行操作。我想要做的是,当有人在列表中按下“阿森纳”时,它会打开列表中的阿森纳类等等。我是 c sharp 和 android 编码的新手,所以如果这很简单,我很抱歉,在此先感谢您的帮助

到目前为止,这是我的代码:

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace App
{
[Activity(Label = "PremierLeague")]
public class Test : ListActivity {
    string[] prem;
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        prem = new string[] { "Arsenal", "Aston Villa", "Cardiff City", "Chelsea", "Crystal Palace", "Everton", "Fulham", "Hull City", "Liverpool", "Manchester City", "Manchester United", "Newcastle United", "Norwich City", "Southampton", "Stoke City", "Sunderland", "Swansea City", "Tottenham Hotspur", "West Bromwich Albion", "West Ham United" };

        ListAdapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, prem);
        }
    }
}
4

1 回答 1

0

您必须覆盖OnListItemClick

protected override void OnListItemClick (ListView l, View v, int position, long id)

{

    base.OnListItemClick (l, v, position, id);

}

于 2013-08-20T17:20:30.183 回答