Populate Listview in TabHost1 on Activity_Create

b4AMarkO

Member
Licensed User
Longtime User
Can I?
I have created the TabHost1 no problem and created the Layouts ( page1, page2, page3, page4)

On page3 layout I added the ListView called LV1 the code below shows how I am trying to get it done .... but its not working ,,,,,, Do I need to wait till the Tab is created first? or how do I make this happen at startup of app

B4X:
Sub Globals
   Dim TabHost1 As TabHost
   Dim txtName, txtDescription, txtColor As EditText
   Dim LV1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main")
   Activity.Title = "My Title"
   Dim bmp1, bmp2 As Bitmap
   bmp1 = LoadBitmap(File.DirAssets, "ic.png")
   bmp2 = LoadBitmap(File.DirAssets, "ic_selected.png")
   
   'TabHost1.AddTab("Tag Search", "page1")
   TabHost1.AddTabWithIcon ("Search", bmp1, bmp2, "page1") 'load the layout file of each page
   TabHost1.AddTab("Alerts", "page2") 
   TabHost1.AddTab("Calls", "page3")
   TabHost1.AddTab("Map", "page4")
   
   
       LV1.Initialize("LV1")
   For i = 1 To 10
       LV1.AddSingleLine("Item #" & i)
   Next
   
   
End Sub
 

mangojack

Well-Known Member
Licensed User
Longtime User
If you have added LV1 to page3 using the Designer then remove this line ...
B4X:
LV1.Initialize("LV1")

Cheers mj
 
Upvote 0

b4AMarkO

Member
Licensed User
Longtime User
If you have added LV1 to page3 using the Designer then remove this line ...
B4X:
LV1.Initialize("LV1")

Cheers mj

That did the Trick - its working great Now!

I am using the trial - coming from VB I am loving this ... I may purchase this in the next day or so .... just need to see if I can build a simple database which is what the listview is for .. if I can this this will get done what I need

Your help was much appreciated
B4AMarkO also known as vbMarkO
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
MarkO .. as another VB'er ... B4a has opened so many more windows (pun unintended)
Among other things ,finding that SQLite databases are not as complicated as they once appeared to be..

Cheers mj
 
Upvote 0
Top