Android - 拖放 - 列表重新排列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1940117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:51:51  来源:igfitidea点击:

Android - drag and drop - list rearrange

androidlistdrag-and-drop

提问by wouter88

How can I create a list where I can rearrange list items with dragging list rows to another row and so on (to change to order)?

如何创建一个列表,在其中我可以通过将列表行拖动到另一行来重新排列列表项(以更改顺序)?

Just like on the HTC Hero in the clocks app where you can rearrange the order of clocks?

就像在时钟应用程序中的 HTC Hero 上一样,您可以重新排列时钟的顺序?

采纳答案by Bo.

Pay special attention to this one

特别注意这个

com.android.music.TouchInterceptor

com.android.music.TouchInterceptor

回答by ericharlow

Even though this question is already answered. I struggled using the music app as an example, so I created a simple Drag and Drop List project to help others that can be found here

尽管这个问题已经回答了。我努力使用音乐应用程序作为例子,所以我创建了一个简单的拖放列表项目来帮助其他人,可以在这里找到

回答by heycosmo

You can also try my recent implementation here:

你也可以在这里尝试我最近的实现:

It gives smooth scrolling while dragging and supports list items with arbitrary heights. Lots of jumpy behavior has also been removed as compared to the TouchInterceptor.

它在拖动时提供平滑滚动并支持任意高度的列表项。与 TouchInterceptor 相比,还删除了许多跳跃行为。

回答by CaseyB

It's in platform/packages/apps/Music/src/com/android/music/TouchInterceptor.java. Here's a direct link:
https://android.googlesource.com/platform/packages/apps/Music/+/master/src/com/android/music/TouchInterceptor.java

它在platform/packages/apps/Music/src/com/android/music/TouchInterceptor.java. 这是一个直接链接:https:
//android.googlesource.com/platform/packages/apps/Music/+/master/src/com/android/music/TouchInterceptor.java

回答by yanchenko

Hint: download the android sourcesand have a look how the Music app (packages\apps\Music) implements this functionality.

提示:下载android 源代码并查看音乐应用程序 ( packages\apps\Music)如何实现此功能。