Android GridView自定义拖放

雷·莱巴

我有一个gridview,我需要实现拖放功能。我一直在尝试找到可能适合我的问题但仍然没有运气的可能的解决方案或现有的库。

这是我需要实现的拖放的前后示意图:

在此处输入图片说明

红色方块是不能拖动或放下的项目。蓝色的是可拖动的,可以放在任何行的任何图块上,而不能放在红色的图块上。白色图块只是占位符,它们被放置为第一列上有红色图块。

Now, when tile A is dragged on the 3rd row, as you can see, they go side by side, not swapped, even if put on top of tile C. The number of white tiles is depending on the number of blue tiles per row, an arraylist is assigned on each row, so it'll just follow. My real problem is that all examples on gridview drag and drop is that tiles swaps or the whole grid follows the flow of items.

My plan to implement this:

  1. When long pressed on a tile to be dragged, it will show a tile that looks like that tile, only larger and lesser opacity.
  2. When dropped on a certain position, will compute for the row.
  3. Adjust arraylists and notifydatasetchanged.

Here's breaking down the problem to slightly smaller problems:

  1. How can I make a larger tile of the long pressed tile?
  2. Is it possible to get the position where the enlarged tile is dropped?
Lei Leyba

我最终编辑了http://code.google.com/p/android-gridview-drag-and-drop/以适应我的问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章