B4J Question Simple ListView

ElliotHC

Active Member
Licensed User
I need to display a simple list which will have a time in seconds, then a name.

I'd like to fill the list with times and then sort them numerically but I don't seem to even have any entries.

I've created the ListView in the designer "ListView_Times"

Here is my code:

B4X:
Private ListView_Times as listview ' Created with 'generate Dim' in designer 

' On Start
ListView_Times.Initialize("ListView_Times")
ListView_Times.Enabled = True

' Main code
ListView_Times.ClearSelection

ListView_Times.Items.Add("1.040 Dave Smith")
ListView_Times.Items.Add("1.001 Paul Jones")

My box is empty?
 

DonManfred

Expert
Licensed User
Created with 'generate Dim' in designer
So i expect you are loading this Layout.
In this case you should NOT initialize the Listview. It is done once you loaded the layout.
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private ListView1 As ListView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    ListView1.Items.Add("Test1")
    ListView1.Items.Add("Test2")
    MainForm.Show
End Sub
 

Attachments

Top