开发者

Why does monodroid click event not work?

开发者 https://www.devze.com 2023-03-24 10:43 出处:网络
I am trying to make a click event for a ListView in monodroid. public class QuizMenuActivity : Activity

I am trying to make a click event for a ListView in monodroid.

public class QuizMenuActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.Menu);

        ListView menuList = FindViewById<ListView>(Resource.Id.ListView_Menu);

        string[] items = new string[]
            { 
                GetString(Resource.String.menu_item_play),
                GetString(Resource.String.menu_item_scores),
                GetString(Resource.String.menu_item_settings),
                GetString(Resource.String.menu_item_help)
            };

        ArrayAdapter<string> adapt = new ArrayAdapter<string>(this, Resource.Layout.MenuItem, items);
        menuList.Adapter = adapt;
    }
}

I tried

This

            menuList.Click +=new EventHandler(menuList_Click);

   void menuList_Click(object sender, EventArgs e)
        {
            // stuff here
        }

I tried

menuList.Click += (sender, e) => { };

They all just hang and say s开发者_开发问答omething like

This is the next statement to execute when this thread returns from the current function.

No other errors are displayed.

It dies right on the creation of the click event. I got nothing in the actual click event.


You probably want menuList.ItemClick instead of Click.

0

精彩评论

暂无评论...
验证码 换一张
取 消