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