弹出窗口没有点击

时间:2018-04-10 17:02:17

标签: c# xamarin

我有一个listview,当我进行长时间点击时,它将该项添加到我的数据库,但是想将其切换为弹出窗口。

我在网上关注了xamarin文档,但是当我点击listview项目时,它应该提供两个选项,无论是“关注还是不关注”。

    public void EListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
    {
        var popup = new PopupMenu(this, eListView.GetChildAt(e.Position));
        popup.Inflate(Resource.Layout.SEMenu);
        popup.MenuItemClick += (s, a) =>
        {
            switch (a.Item.ItemId)
            {
                case Resource.Id.FollowEvent:
                    Toast.MakeText(this, "TEST follow", ToastLength.Short).Show();
                break;
                case Resource.Id.DontFollowEvent:
                    Toast.MakeText(this, "TEST dont follow", ToastLength.Short).Show();
                break;
                default:
                {
                    Toast.MakeText(this, "An error has occured, please try again.", ToastLength.Short).Show();
                }
                break;
            }
        };
    }

XML文件

<?xml version="1.0" encoding="utf-8" ?>
<!--For all properties see: 
http://developer.android.com/guide/topics/resources/menu-resource.html-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@+id/FollowEvent" android:title="Follow Event" showAsAction="always"/>
<item android:id="@+id/DontFollowEvent" android:title="Don't Follow Event" showAsAction="always"/>

</menu>

0 个答案:

没有答案