Android Question How can I sort listview items

Beja

Expert
Licensed User
Longtime 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
Longtime User
Thanks Erel, but standard list doesn't support more than two items (I think).. my listview has raws of 9 items each
 
Upvote 0

udg

Expert
Licensed User
Longtime 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)
 
Upvote 0

Beja

Expert
Licensed User
Longtime 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.
 
Upvote 0

udg

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