Question

I have a gridView I've created from an online example/tutorial and I'm trying to figure out how to change the behavior when a new item is dragged over a previously existing item in the GridView. Currently when a new item is dragged over the gridView it removes the current icon in place (leaving it with the red empty square [icon.png is a grid of empty squares the code uses as a background image])

I've poured through the example's source quite a few times and I can't figure out how to change the behavior of what happens when one item is dragged over the other

Screenshot:

enter image description here

Source code:

https://drive.google.com/file/d/0B6jCh_IJdtoFYWFJMlk5MHhlX3c/edit?usp=sharing

P.S.

I believe the issue may be in either the DragView or DropTarget class. (feel free to download the entire project - I've made the entire thing available for an easy download)

Was it helpful?

Solution

Look at methods onDragEnter and onDragExit in ImageCell. Those two methods are the ones called as your finger passes over a cell on the grid. They set the background of the image view.

onDragEnter: int bg = mEmpty ? R.color.cell_empty_hover : R.color.cell_filled_hover; setBackgroundResource (bg);

onDragExit: int bg = mEmpty ? R.color.cell_empty : R.color.cell_filled; setBackgroundResource (bg);

The color definitions are in mycolor.xml.

Reference: http://blahti.wordpress.com/2012/03/03/improved-drag-drop-for-gridview/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top