在MvxListView Xamarin Android

时间:2017-03-09 09:28:09

标签: android xamarin.android mvvmcross

我正在尝试在我的计划中实施LongClickListener,但存在一些问题

这是我的代码

    protected override void OnCreate(Bundle bundle)
    {
    ...
    ...
    MvxListView mvxListView = FindViewById<MvxListView>(Resource.Id.ListView);
    mvxListView.OnItemLongClickListener = new IOnItemLongClickListener(this);
    ...
    ...}

在这里我写了OnItemLongClickListener

public class IOnItemLongClickListener : Java.Lang.Object, Android.Widget.AdapterView.IOnItemLongClickListener
    {
        private readonly OrderListView orderList;

        public IOnItemLongClickListener(OrderListView orderListView)
        {
            // TODO: Complete member initialization
            this.orderList = orderListView;
        }

        void AdapterView.IOnItemLongClickListener.OnItemLongClick(AdapterView parent, View view, int position, long id)
        {
            clickPosition = position;
            orderList.ViewModel.ShowDetailCommand.Execute(orderList.ViewModel.OrderList[position]);
        }

    }

但是当我运行该程序时,会出现

的问题
  

&#39; AdapterView.IOnItemLongClickListener.OnItemLongClick&#39;明确地说   接口声明不是接口的成员

     

&#39; Droid.Views.OrderListView.IOnItemLongClickListener&#39;才不是   实现接口成员   &#39; Android.Widget.AdapterView.IOnItemLongClickListener.OnItemLongClick(Android.Widget.AdapterView,   Android.Views.View,int,long)&#39;

由于

1 个答案:

答案 0 :(得分:0)

这是方法, 我调用了错误的功能

MvxListView mvxListView = FindViewById<MvxListView>(Resource.Id.ListView);
mvxListView.OnItemLongClickListener = new onListClickListener(this);

...

public class onListClickListener : Java.Lang.Object, Android.Widget.AdapterView.IOnItemClickListener
    {
        //public AcceptedTaskFragment acceptedTaskFragment;
        private readonly OrderListView orderList;

        public onListClickListener(OrderListView orderListView)
        {
            // TODO: Complete member initialization
            this.orderList = orderListView;
        }

        void AdapterView.IOnItemClickListener.OnItemClick(AdapterView parent, View view, int position, long id)
        {
            clickPosition = position;
            orderList.ViewModel.ShowDetailCommand.Execute(orderList.ViewModel.OrderList[position]);
        }

    }