ListView Reorder Items

浪尽此生 提交于 2019-12-06 13:14:48
Orkun Ozen

As far as I know, String resources are static so you cannot manipulate the xml in the code (to change the order, add / remove items ..etc).

But I can think of two solutions for your problem.

  1. Save the order you want in the SharedPreferences and apply it to your String[] in the onCreate() (e.g. save the sequence of your string array index-- creepy but would work, I think)

  2. Learn and start using a SqlLite database if that s what you are trying to avoid :)

Edit

To see how to use SharedPreferences : check the code snippet here http://developer.android.com/guide/topics/data/data-storage.html

It's easy to implement drag/drop functionality to a list on Android 3.0+. Check the docs:

http://developer.android.com/guide/topics/ui/drag-drop.html

If you want a pre-honeycomb solution, try this:

https://github.com/commonsguy/cwac-touchlist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!