B4J Question ListView Problem

Nokia

Active Member
Licensed User
Longtime User
I have put a listview on my form, but when i run in debug or release, I get an error that I need to initialize. even if I initialize, it sill shows up blank.

B4X:
Sub Class_Globals
   Private lvEmailTo As ListView
End Sub

B4X:
Sub LoadEmailList
   Dim su As StringUtils
   EmailList = su.LoadCSV(Main.WrkFld, csvName, csvChar)
   'lvEmailTo.Initialize("lvEmailTo")
     
   For Each Row() As String In EmailList
    For Each Col As String In Row
        Dim lbl As Label
    lbl.Initialize("")
    lbl.Text = SharedMod.DecToString(Col)
    lbl.Font = fx.DefaultFont(14)
        lvEmailTo.Items.Add(lbl)
      Log(lbl.Text)
    Next
   Next
   
   
End Sub
Sub email_Closed

not sure if I am missing something..
 

Nokia

Active Member
Licensed User
Longtime User
You don't need to initialize it in your code. You should add it with the designer and make sure that its name is correct and that you only access it after you call MainForm.RootPane.LoadLayout.

I have this on show..

B4X:
sub show(fOwner As Form)
   
  email.Initialize("frmEmail", 601, 448)
   email.Resizable = True
   email.RootPane.LoadLayout("frmEmail") 'Load the layout file.
   email.Icon = fx.LoadImage(File.DirAssets, "Icon.png")
   email.SetOwner(fOwner)

  lvEmailTo.Visible = False

  email.Show

end sub

as I was typing this I just realized I call the LoadEmailList sub on form initialize and not on show..
 
Upvote 0
Top