如何在Android中使用拖放列表项实现expandablelistview [英] How to implement expandablelistview with Drag and Drop List Items in android

查看:102
本文介绍了如何在Android中使用拖放列表项实现expandablelistview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android中使用带ListItems拖放功能的ExpandableListView,我用google搜索,但是我没有找到带拖放列表项的ExpanadableListView的任何很好的教程或链接。请建议我在哪里可以学习实现ExpanadableListView的拖放。任何教程,示例代码将不胜感激。帮助我。谢谢。

I wan for the ExpandableListView with Drag and Drop of ListItems in Android,i google it but i haven't found any good tutorial or any good link for ExpanadableListView with drag and drop list item. Please suggest me where can i learn to implement drag and drop for ExpanadableListView. Any tutorial,sample code would be appreciated greatly .Help me. Thank you.

推荐答案

拖放的基本思想可以分为两部分,例如更新UI和更新数据。 。更新UI首先从隐藏所选项目开始,然后显示与隐藏项目具有相同值的分离行,这将表明所选项目已准备就绪,现在可以基于touchmove事件在列表视图上移动分离行,当用户握住手,即触摸事件或拖动时发生的任何其他事件,获取用户最后触摸的当前行,删除分离的行并进行数据更新并使可扩展列表视图无效,这将基于新数据集,用户会感觉到该项目已被拖放到列表中。

The basic idea behind drag and drop can be divided into two sections, like updating the UI and updating the data. Updating UI starts with hiding the selected item and show a detached row with the same value as the hidden item, this will show that the selected item is ready to drag, now move the detached row over the list view based on the touchmove event, when the user takes the hand ie the touchup event or any other event that happens while dragging, get the current row at which user touched last , remove the detached row and do the data updation and invalidate the expandable listview, this will redraw the list based on the new set of data and the user will get a feeling that the item is dragged and dropped in the list.

我已经做了类似的事情,请参见

I have done something similar, see this

这篇关于如何在Android中使用拖放列表项实现expandablelistview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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