Android Question How can I sort listview items

Beja

Expert
Licensed User
Hi,
I have a listview with a few items, one of them is time 10:35AM (for example)
I want to sort the ListView on this item.
Your help is appreciated.

p.s.
A function or module will help a lot :)
 

Beja

Expert
Licensed User
Thanks Erel, but standard list doesn't support more than two items (I think).. my listview has raws of 9 items each
 

udg

Expert
Licensed User
Hi Beja,

standard list are designed to hold objects not only primitive types.
So you may define a type with those 9 items you need and then add to the list an object instance of that type.
In pseudo code:
B4X:
..
type mytype=(item#1 as string, item#2 as int...)

dim myobject as mytype
myobject.item#1 = "john"
mybject.item#2 = 1
..
mylist.add(myobject)
 

Beja

Expert
Licensed User
Hi udg,
How is the list sorted then.. I have an item of type Time among the 9 items, that I want the list sorted with.
 

udg

Expert
Licensed User
Have a look at List.SortType in the standard list documentation. It does what you need.
 
Top