B4J Question [SOLVED] CustomListView in a TabPane with data from SQL

JOTHA

Well-Known Member
Licensed User
Longtime User
Hello community,

i have a little problem with a CustomListView in a TabPane with data from SQL.
When i want to show more than 1 item from SQLlite it doesn't show.

In the CustomListView is only shown 1 item on the top of the list.

I have this code:
B4X:
...
Private ResultSet1 As ResultSet
    ResultSet1 = SQL1.ExecQuery("SELECT * FROM Schulbildung ORDER BY SBD_004 DESC, SBD_003 ASC")  '-- WHERE SBD_002 = 'TN-IDNR: 611D2902XX' ")
    Do While ResultSet1.NextRow

        Layout_008_CustomListView_001.Add(CreateListItem_Schule("", 1130, 230), ""&ResultSet1.GetString("SBD_030")&"")

        Layout_008_P01_Schule_01_ComboBox_Beginn_Monat.Value = ResultSet1.GetString("SBD_003")
        Layout_008_P01_Schule_01_ComboBox_Beginn_Jahr.Value = ResultSet1.GetString("SBD_004")
        Layout_008_P01_Schule_01_ComboBox_Ende_Monat.Value = ResultSet1.GetString("SBD_005")
        Layout_008_P01_Schule_01_ComboBox_Ende_Jahr.Value = ResultSet1.GetString("SBD_006")
        Layout_008_P01_Schule_01_TextField_Schulart.Text = ResultSet1.GetString("SBD_007")
        Layout_008_P01_Schule_01_TextField_NAME_der_Schule.Text = ResultSet1.GetString("SBD_008")
        Layout_008_P01_Schule_01_TextField_Schule_ORT.Text = ResultSet1.GetString("SBD_009")
        Layout_008_P01_Schule_01_TextField_Schule_LAND.Text = ResultSet1.GetString("SBD_010")
        Layout_008_P01_Schule_01_TextField_Schule_ABSCHLUSS.Text = ResultSet1.GetString("SBD_011")
        Layout_008_P01_Schule_01_CheckBox_ZEUGNIS_vorhanden.Checked = ResultSet1.GetString("SBD_012")
        Layout_008_Label_026.Text = ResultSet1.GetString("SBD_026")
        Layout_008_Label_027.Text = ResultSet1.GetString("SBD_027")
        Layout_008_Label_028.Text = ResultSet1.GetString("SBD_028")
        Layout_008_Label_029.Text = ResultSet1.GetString("SBD_029")
        Layout_008_P01_Label_SBD_IDNR.Text  = ResultSet1.GetString("SBD_030")

Loop

    Layout_008_CustomListView_001.AsView.Visible = True
    Layout_008_P01_Schule_01.Visible = True
...
... and this is the code for "CreateListItem_Schule":
B4X:
Sub CreateListItem_Schule(Text As String, Width As Int, Height As Int) As Pane
   
    Dim Layout_008_CustomListView_Pane As Pane
    Layout_008_CustomListView_Pane.Initialize("")
    Layout_008_CustomListView_Pane.LoadLayout("Layout_008a_Schulbildung_Einzeln")
    Return Layout_008_CustomListView_Pane
   
End Sub

Does anyone see the mistake?
 

JOTHA

Well-Known Member
Licensed User
Longtime User
Hello Erel,

thank you for helping me.
I used B4XView and changed the code to ...
B4X:
    Dim pnl As B4XView = xui.CreatePanel("")
    pnl.SetLayoutAnimated(1000, 0, 0, 1130, 230)
    pnl.LoadLayout("Layout_008a_Schulbildung_Einzeln")
    Return pnl
... also the other Sub ...
B4X:
...
Private ResultSet1 As ResultSet
    ResultSet1 = SQL1.ExecQuery("SELECT * FROM Schulbildung ORDER BY SBD_004 DESC, SBD_003 ASC")  
    Do While ResultSet1.NextRow

Layout_008_CustomListView_001.Add(CreateListItem_Schule("", 1130, 230), ""&ResultSet1.GetString("SBD_030")&"")
...
Loop
... but the result is the same ... it shows only 1 item instead of 5 items.

Could it be that the 5 items are laying as a "staple" one-over-the-other in the same place so that i only can see the last one on top?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Could it be that the 5 items are laying as a "staple" one-over-the-other in the same place so that i only can see the last one on top?
No.
B4X:
pnl.SetLayoutAnimated(1000, 0, 0, 1130, 230) 'why 1000? Set it to 0.

Put a breakpoint in this loop and make sure that there are actually 5 rows.
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
Thank you Erel for your help!
pnl.SetLayoutAnimated(1000, 0, 0, 1130, 230) 'why 1000? Set it to 0.
I wanted to animate the Pane with a duration of 1000 milliseconds ... and that was the reason why only 1 item was shown!
Without this (set to "0") it works!
 
Upvote 0
Top