Android 图像从一种布局拖动并移动到另一种布局
是否可以将 ImageView 从一种布局移动到另一种布局。如果我将图像从一个布局移动到另一个布局,则会出现异常“java.lang.IllegalArgumentException:给定视图不是 xyz 布局的子级”
如果我长按应用程序图标,应用程序将从应用程序列表视图移动到工作区。启动器是如何做到这一点的。如何将应用程序图标从一种布局移动到另一种布局?
Is it possible to move a ImageView from one layout to another. If i move an image from one layout to another i get an exception "java.lang.IllegalArgumentException: Given view not a child of xyz layout"
If i long press on a application icon, the app is moved from app list view to workspace. How does the launcher do this. How is it able to move the app icon from one layout to another layout ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会有不同的想法。您的布局应该能够根据视图表示的数据创建和删除相同类型的视图,而不是移动实际的视图对象。听起来您正在定期从一种布局拖/放到另一种布局。当在新布局中发生放置时,该布局应该知道被放置的数据,并能够基于该数据创建新视图。原始布局应该意识到它已经丢失了这些数据,并删除了原始视图。考虑视图所代表的数据而不是视图对象本身可能是这里的方法。
I would think of it differently. Instead of moving the actual view object, your layouts should be able to create and remove the same type of view based on the data that the view represents. It sounds like you're doing a regular drag/drop from one layout to another. When the drop occurs in the new layout, this layout should be aware of the data that is dropped and be able to create a new view based on this data. The original layout should be aware that it has lost this data, and remove the original view. Thinking in terms of the data that the view represents instead of the view object itself is probably the way to go here.