【问题标题】:Disable drag and drop for certain cellViews in ListView xamarin android?在ListView xamarin android中禁用某些cellViews的拖放?
【发布时间】:2017-07-26 21:16:46
【问题描述】:

我参考下面的链接为 xamarin listview 实现了拖放

https://github.com/pnavk/Drag-and-Drop-ListView

但我需要根据某些条件禁用 listView 的几个项目的拖放。帮助表示赞赏。 谢谢!

【问题讨论】:

    标签: listview xamarin.android xamarin.forms


    【解决方案1】:

    但我需要根据某些条件禁用 listView 的几个项目的拖放。感谢您的帮助。

    您可以在DraggableListView.csOnLongPress 活动中进行。在OnLongPress事件中,长按项目的位置和已经被检索到,所以你需要做的只是检索长按项目根据你的“某些条件”添加一个if语句:

    public void OnLongPress (MotionEvent e)
    {
            mTotalOffset = 0;
    
            int position = PointToPosition (mDownX, mDownY);
    
            if (position < 0 || !LongClickable)
                return;
    
            //added codes
            var item=Adapter.GetItem(position);
            //if the user long pressed a Vegetables, then it can't be drag and drop
            if (item != null && item.ToString() == "Vegetables")
            {
                return;
            }
    
            int itemNum = position - FirstVisiblePosition;
    
            ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      • 2020-06-01
      • 2014-07-11
      • 1970-01-01
      • 2015-02-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多