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

Discussion in 'B4J Questions' started by JOTHA, Jul 4, 2019.

  1. JOTHA

    JOTHA Well-Known Member Licensed 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:
    Code:
    ...
    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(
    ""1130230), ""&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":
    Code:
    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?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    1. Never load a layout before you set the container size.
    2. I recommend you to use B4XView instead of Pane.
    3.
    Code:
    Dim pnl As B4XView = xui.CreatePanel("")
    pnl.SetLayoutAnimated(
    000, Width, Height)
    pnl.LoadLayout(...)
    Return pnl
     
  3. JOTHA

    JOTHA Well-Known Member Licensed User

    Hello Erel,

    thank you for helping me.
    I used B4XView and changed the code to ...
    Code:
    Dim pnl As B4XView = xui.CreatePanel("")
        pnl.SetLayoutAnimated(
    1000001130230)
        pnl.LoadLayout(
    "Layout_008a_Schulbildung_Einzeln")
        
    Return pnl
    ... also the other Sub ...
    Code:
    ...
    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(
    ""1130230), ""&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?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    No.
    Code:
    pnl.SetLayoutAnimated(1000001130230'why 1000? Set it to 0.
    Put a breakpoint in this loop and make sure that there are actually 5 rows.
     
  5. JOTHA

    JOTHA Well-Known Member Licensed User

    Thank you Erel for your help!
    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!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice