Android GridView reorder elements via Drag and Drop

后端 未结 8 1269
温柔的废话
温柔的废话 2020-12-12 17:43

I have a GridView in an application I am working on. I would like to be able to reorder the items in the GridView via drag-and-drop. I have found lots of help for ListViews

8条回答
  •  时光说笑
    2020-12-12 18:14

    Google recently released a few code labs a few months back. https://codelabs.developers.google.com/codelabs/android-training-adaptive-layouts/index.html?index=..%2F..%2Fandroid-training#0

    You can check the solution to it here https://github.com/google-developer-training/android-fundamentals-apps-v2/tree/master/MaterialMe-Resource

    They make grid layout with movable cards that can be dragged and dropped anywhere in the layout using the itemTouchHandler.

    The more detailed code on how to do the drag and drop is here You need to look into the Task 3: Make your CardView swipeable, movable, and clickable section

提交回复
热议问题