实现拖放放大器;下降姜饼 [英] Implement Drag & Drop in Gingerbread

查看:139
本文介绍了实现拖放放大器;下降姜饼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道我可以实现拖放放大器;下降的Andr​​oid的姜饼版本。据我所知姜饼不支持在默认情况下。

I need to know how I can implement Drag & Drop in Android for the Gingerbread version. As I know Gingerbread doesn't support that by default.

我有codeD:一个的ViewGroup 类来保存动态添加的孩子,每个孩子应该经过了漫长的点击 能够通过手指点击/移动,到达感动。为了解决这个问题,我有一个 OnLongClickListener 连接到每个查看的孩子和我的的ViewGroup 实施了这两种方法 onTouch(),以获得下/上/移动事件和方法 onLongClick()来应对长按每个孩子。

What I have coded: a ViewGroup class to hold dynamic added child, each child should after a long click be able to get moved through a finger tap/move. To solve this, i have a OnLongClickListener attached to each View's child and my ViewGroup have implemented both the methods onTouch() to get the down/up/move events and the method onLongClick() to response to the long click on each child.

现在我的问题是:我长按一个孩子,我可以移动它,可以结束通过 ACTION_UP 事件的动作。但是,我不能长时间再次点击这个孩子 - 是有办法或库,可以处理

Now my problem is as follows: I long tap a child, I can move it and can end the action through the ACTION_UP event. But, I can't long tap this child again - is there a way or library that can handle that?

我想,我并不需要一个真正的D&放大器; d库/功能,因为我只将下令在这方面的一些图标的ViewGroup - 每个孩子被添加到<通过code C>的ViewGroup $ C $,所以我没有一个真正的DropTarget我想。

I think, I don't need a really D&D library/function because I only will order some icons in this ViewGroup - each child gets added to the ViewGroup via code, so I don't have a really DropTarget I think.

推荐答案

看项目的的https:// github上.COM / thquinn / DraggableGridView 。这code真的帮了我。

Look at the project at https://github.com/thquinn/DraggableGridView. This code really helped me out.

按照 onLayout() onTouch() DraggableGridView 类。让我知道,如果这是/是没有帮助的。这是非常相似的问候您的情况的ViewGroup 并添加视图。

Follow the onLayout() and the onTouch() in the DraggableGridView class. Let me know if this was/wasn't helpful. It's very similar to your situation in regards to ViewGroup and adding views.

这篇关于实现拖放放大器;下降姜饼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆