添加textView到拖放界面 – Android / Java

我有一个gridView,我从以下教程/示例构建:

Improved Drag-Drop for an Android GridView

原样 – 示例的源(可从下面的链接下载)允许用户拖放新的方形imageView并将其放在gridview中。

我现在想要完成的是能够创建一个可以拖放的textView(与imageView一起),实际上创建一个带有可以拖放的标题的文件夹。

到目前为止 – 我已经设法创建我自己的自定义(新的瓷砖等以及一个editText,点击成为textView)版本的gridView – 以及istantiated一个textView – 我似乎无法让它移动拖动时使用imageView。

/** * Interface defining an object that reacts to objects being dragged over and dropped onto it. * */ public interface DropTarget { /** * Handle an object being dropped on the DropTarget * * @param source DragSource where the drag started * @param x X coordinate of the drop location * @param y Y coordinate of the drop location * @param xOffset Horizontal offset with the object being dragged where the original * touch happened * @param yOffset Vertical offset with the object being dragged where the original * touch happened * @param dragView The DragView that's being dragged around on screen. * @param dragInfo Data associated with the object being dragged * */ void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo); /** * React to something started to be dragged. */ void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo); /** * React to something being dragged over the drop target. */ void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo); /** * React to a drag */ void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo); /** * Check if a drop action can occur at, or near, the requested location. * This may be called repeatedly during a drag, so any calls should return * quickly. * * @param source DragSource where the drag started * @param x X coordinate of the drop location * @param y Y coordinate of the drop location * @param xOffset Horizontal offset with the object being dragged where the * original touch happened * @param yOffset Vertical offset with the object being dragged where the * original touch happened * @param dragView The DragView that's being dragged around on screen. * @param dragInfo Data associated with the object being dragged * @return True if the drop will be accepted, false otherwise. */ boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo); /** * Estimate the surface area where this object would land if dropped at the * given location. * * @param source DragSource where the drag started * @param x X coordinate of the drop location * @param y Y coordinate of the drop location * @param xOffset Horizontal offset with the object being dragged where the * original touch happened * @param yOffset Vertical offset with the object being dragged where the * original touch happened * @param dragView The DragView that's being dragged around on screen. * @param dragInfo Data associated with the object being dragged * @param recycle {@link Rect} object to be possibly recycled. * @return Estimated area that would be occupied if object was dropped at * the given location. Should return null if no estimate is found, * or if this target doesn't provide estimations. */ Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo, Rect recycle); // These methods are implemented in Views void getHitRect(Rect outRect); void getLocationOnScreen(int[] loc); int getLeft(); int getTop(); }