That's true.Don't waste your time with ListView. Use xCustomListView instead.
Sort a listview that contains icon.bitmaps by string(line1) or string(line2).What exactly do you want to do.
You ask questions but i do not understand your problem.
Expose exactly your problem what do you want to do ?
Then it would be much easier to give concrete advice.
Sub Sort3Lists2SortedListView
'create 'SortedList' listview
'create 4 lists:
' list1 is the name which will be sorted
' list2 is original name not sorted
' list3 is package name
' list4 is icon.bitmap
'init all 4 lists
'add your data to the 3 lists
' example add all installed apps to the lists
' for each app installed
' List1.Add(name) 'name of app
' List3.Add(packName)
' List4.Add(icon.Bitmap)
List2=List1 'list2 is to keep original list sequence. Along with List3, & List4
List1.Sort(True) 'sort list1 but leave other lists alone
Dim SearchFor As String
Dim N As Int
For N = 0 To List1.Size -1 'pick a line to search for
SearchFor=List1.Get(N)
Dim MyLine As String
For II = 0 To List2.Size -1 'search for line1 in list 2 to get list item #
MyLine = List2.Get(II)
If MyLine.Contains(SearchFor) Then
SortedList.AddTwoLinesAndBitmap2(List2.Get(II),List3.Get(II),list4.Get(II),List3.Get(II))
End If
Next
Next
Lv3 = SortedList 'sortedlist is never visible, but LV3 (listview) is
End Sub
Sort3Lists2SortedListView:List2=List1 'list2 is to keep original list sequence. Along with List3, & List4
Maybe later, but for now list2=list1 is working?I suspect you are about to be let down by this line:
+1If you are trying to run a sort directly on a listview then I think that you are using the wrong approach. In this situation I have my data items in a List; I sort the list as required,
then remove, replace and repopulate the listview.
Maybe later, but for now list2=list1 is working?
I'll check in a half-hour when I'm back in front of B4A and an Android device to test it on.
List2=List1 'list2 is to keep original list sequence. Along with List3, & List4
Now I'm ready for my 9am conference.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Type AppType(AppName, PackageName As String, Icon As Bitmap, Price As Double)
Dim AppList As List
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Dim Button1, Button2, Button3 As Button
Private LV3 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
CreateAppList
AppListToListView
DeslectAllSortButtons
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
'''xui.MsgboxAsync("Hello world!", "B4X")
AppList.SortType("AppName", True)
AppListToListView
DeselectAllSortButtons
Button1.Color = Colors.Green
End Sub
Sub Button2_Click
AppList.SortType("PackageName", True)
AppListToListView
DeselectAllSortButtons
Button2.Color = Colors.Green
End Sub
Sub Button3_Click
AppList.SortType("Price", True)
AppListToListView
DeselectAllSortButtons
Button3.Color = Colors.Green
End Sub
Sub DeselectAllSortButtons
Button1.Color = Colors.Gray
Button2.Color = Colors.Gray
Button3.Color = Colors.Gray
End Sub
Sub CreateAppList
AppList.Initialize
For I = 1 To 6
Dim TempApp As AppType
TempApp.AppName = "Name " & Array As String("One", "Two", "Three", "Four", "Five", "Six")(I - 1)
TempApp.PackageName = "Package " & I
TempApp.Icon = LoadBitmap(File.DirAssets, I & ".png")
TempApp.Price = Array As Double(3.14, 1.59, 2.65, 3.58, 9.79, 3.23)(I - 1)
AppList.Add(TempApp)
Next
End Sub
Sub AppListToListView
Dim WhichCurrency As Int = 1
Dim CurrencySymbol As String = "$€¥".CharAt(WhichCurrency)
Dim ConversionRate As Double = Array As Double(1, 0.9392, 133.8885)(WhichCurrency)
LV3.Clear
For I = 0 To AppList.Size - 1
Dim TempApp As AppType = AppList.Get(I)
Dim PrettyPrice As String = CurrencySymbol & NumberFormat2(TempApp.Price * ConversionRate, 1, 2, 2, False)
LV3.AddTwoLinesAndBitmap(TempApp.AppName & " " & PrettyPrice, TempApp.PackageName, TempApp.Icon)
Next
End Sub
This is why your an 'Expert'
You could define a Type variable holding the different data
In this situation I have my data items in a List; I sort the list as required, then remove, replace and repopulate the listview.