拖放从一个线性布局按钮到另一个线性布局 [英] Dragging and Dropping a button from one Linear Layout to another Linear Layout

查看:176
本文介绍了拖放从一个线性布局按钮到另一个线性布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这10个按键的线性线性布局。我需要拖动这些按钮将它添加到在他们被丢弃的顺序另一个线性布局(水平)。请帮我做这个?

I have a linear linear layout with 10 buttons in it. I need to drag these buttons and add it into another linear layout(Horizontal) in the order they are dropped. Please help me in doing this?

推荐答案

我就怎么做拖放的和以后的API级别8运行的应用提出了一些建议。我学的是源$ C ​​$ C为Android发射模块,并了解了拖放框架,他们把这个地方准备就绪。我发现,是在其上构建了良好的基础。我已经在一系列在我的博客的文章写上去的重点班(DragSource上,DropTarget的,DragLayer,的DragController)的细节。一个解决办法是太长,张贴在这里,所以我是指你的笔记:

I have some suggestions on how to do drag-drop in apps running on API level 8 up and beyond. I studied the source code for the Android Launcher module and learned about the drag-drop framework they put in place for that. I have found that is a good foundation on which to build. I have written up the details of the key classes (DragSource, DropTarget, DragLayer, DragController) in a series of articles on my blog. A solution is too long to post here, so I refer you to those notes:

(一)的移动视图在Android中 - 第2部分,拖放 - 这种描述的基本框架,包括一个演示程序。由于我主要关注的是学习拖放,我用pcated AbsoluteLayout类现在去$ P $。在后续的这一个(第三部分)是值得看的太多,因为它发展的DropTarget进一步的概念。

(a) Moving Views In Android - Part 2, Drag and Drop - this describes the basic framework and includes a demo app. Since I was primarily concerned with learning about drag-drop, I used the now deprecated AbsoluteLayout class. The follow-on to this one (Part 3) is worth looking at too because it develops further the notion of DropTarget.

(二)的拖放一个Android的GridView - 一个演示应用程序,展示了如何使用网格视图的拖放框架。更妙的是,它说明了如何通过没有AbsoluteLayout。在这种情况下,DragLayer和其他类更了解的那种,他们正在与布局。

(b) Drag-Drop for an Android GridView - a demo app that shows how to use the drag-drop framework for grid views. Even better, it illustrates how to get by without AbsoluteLayout. In this case, the DragLayer and other classes know more about the kind of layouts they are working with.

演示应用程序演示的图像和文字的观点被拖动。底层code是非常普遍:任何视图中可拖动。你将与​​拖动按钮面临的一个问题是确保拖动操作的启动将不会与正常的点击操作的按钮的功能相混淆。考虑使用一个长按开始拖动序列。

The demo apps illustrate images and text views being dragged. The underlying code is perfectly general: any view can be dragged. A problem you will face with dragging buttons is making sure that the start of a drag operation will not be confused with the normal click handling that buttons do. Consider using a long click to initiate a drag sequence.

这篇关于拖放从一个线性布局按钮到另一个线性布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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