开发者

Is there an easy way to drag items around in a ListView to change their order?

开发者 https://www.devze.com 2023-01-14 05:18 出处:网络
Let\'s say I have a ListView of items: Cat Dog Mouse And these are bound to the ListView via an adapter to a database.

Let's say I have a ListView of items:

  • Cat
  • Dog
  • Mouse

And these are bound to the ListView via an adapter to a database.

What I want to be able to do is to be able to re-order the list view,. For example I want to somehow drag "Mouse" up to the top of the list above "Cat". Once I have an order set, I then want to "save" the list and its order back to the database.

Is there any way to do this? Has someone made such a custom ListView that I could use? The only alternative I can think of is to long press on a list view item and have开发者_StackOverflow社区 a "Move up by one", "Move to top", etc. context menu that moves items around in the list.


Android's music application does that with the playlist. Check it's source code here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号