[英]Drag-Drop Android Launcher / GridView Issue - Android / Java
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
. 我有一个从在线示例/教程创建的
gridView
,我试图弄清楚将新项目拖到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]) 当前,当将新项目拖到
gridView
它会删除当前图标(将其保留为红色的空正方形[icon.png是空正方形的网格,代码用作背景图像))
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 我已经多次浏览了示例的源代码,但我不知道如何更改将一个项目拖到另一个项目上时发生的行为
https://drive.google.com/file/d/0B6jCh_IJdtoFYWFJMlk5MHhlX3c/edit?usp=sharing https://drive.google.com/file/d/0B6jCh_IJdtoFYWFJMlk5MHhlX3c/edit?usp=sharing
PS 聚苯乙烯
I believe the issue may be in either the DragView or DropTarget class. 我认为问题可能出在DragView或DropTarget类中。 (feel free to download the entire project - I've made the entire thing available for an easy download)
(可以免费下载整个项目-我已经将整个内容提供了一个简单的下载)
Look at methods onDragEnter and onDragExit in ImageCell. 查看ImageCell中的onDragEnter和onDragExit方法。 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 ? onDragEnter:int bg = mEmpty吗? R.color.cell_empty_hover : R.color.cell_filled_hover;
R.color.cell_empty_hover:R.color.cell_filled_hover; setBackgroundResource (bg);
setBackgroundResource(bg);
onDragExit: int bg = mEmpty ? onDragExit:int bg = mEmpty吗? R.color.cell_empty : R.color.cell_filled;
R.color.cell_empty:R.color.cell_filled; setBackgroundResource (bg);
setBackgroundResource(bg);
The color definitions are in mycolor.xml. 颜色定义在mycolor.xml中。
Reference: http://blahti.wordpress.com/2012/03/03/improved-drag-drop-for-gridview/ 参考: http : //blahti.wordpress.com/2012/03/03/improved-drag-drop-for-gridview/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.