How to sort Android ListView by Column wise?

泪湿孤枕 提交于 2019-12-12 02:12:51

问题


I've a list view in that it contain a header (like addHeaderView(layout) and Header having three columns) and when i click on first column of header then the list is to be sorted according to the values lied into the first column, then if i click second column of header then list is being sorted according to second column and so on. But now its working like whenever i click any column the list is being sorted based on first column so how can i achieve my problem?

Thanks, @nag.


回答1:


  1. Put header for column title in listview.
  2. for multi column in listview try this.
  3. to sorting listview column, sort the list (String array[]) you providing in listview.



回答2:


Well in case like this in the listener you sort you adapter differently , that's it in case the A button i pressed than you sort the adapter according some criteria A, if the B button i pressed than than you sort the adapter according some criteria B. after every change you call notifyDataSetChanged();



来源:https://stackoverflow.com/questions/7441189/how-to-sort-android-listview-by-column-wise

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