2017-07-26 68 views

回答

0

但我需要禁用基于特定条件的少数listView项目的拖放。帮助表示赞赏。

您可以在DraggableListView.csOnLongPress事件中完成。

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; 

     ... 
} 
:在 OnLongPress事件,以及长压项已被取回,所以你需要做的只是检索什么长压项目根据你的“特定标准”添加if语句的位置