Android Question [FIXED] xCustomlistview with JdbcSQL

Hi, I need someones help for solve my problem. I'm developing an app which directly connect with remote MySQL database using JdbcSQL and display data using xCustomlistview.
In xcustomlistview 1 use 2 panel to show data as 2 columns (Like grid)

This is what its looks like in design view,
Capture1.PNG


This is the code I've used to create the card,
B4X:
Private Sub CreateItem(Width As Int, Title1 As String, Image1 As String, price1 As String,Title2 As String, Image2 As String,price2 As String) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    Dim height As Int = 180dip
    If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then height = 310dip
    p.SetLayoutAnimated(0, 0, 0, Width, height)
    p.LoadLayout("Card")
    
    lbl_price1 .Text=price1
    lbl_price2 .Text=price2
    lbl_title1 .Text=Title1
    lbl_title2 .Text=Title2
 
    Return p
End Sub

And this is the code I've used to display data,

B4X:
ProgressDialogShow2("please wait..",False)
        Dim SenderFilter As Object = connection.mysql.ExecQueryAsync("SQL", "SELECT * FROM products", Null)
        Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As JdbcResultSet)
        If Success Then
            Log("success")
            Do While rs.NextRow
                    clv.Add(CreateItem(clv.AsView.Width,rs.GetString("product_name"),Null,rs.GetString("price"),"title2",Null,"price2"),"")
                        Loop
            rs.Close
            ProgressDialogHide
        
        Else
            Log(LastException)
        End If

This will only add data to the panel 1. I want to add data to both panels. I cannot move into next row to get data and add them in same row in xcustomlistview. So how can I do that? in mysql library we can use "position" option. but in JdbcSQL there is no anything like that. I hope you guyz understand what I'm try to say. If anyone know how to solve this problem please let me know.

Thank you.
 
Erel, Can you show me a way to get data from next row? for example, I want to get data from row 1 and 2 (Database) and add them on xcustomlistview as 2 cells(panels).
I've tried using "rs.Next" but it give me an error

java.sql.SQLException: After end of result set
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Do While rs.NextRow
                    Dim Title1 As String = rs.GetString("product_name")
                   'get all other fields you need
                   If rs.NextRow Then
                      Dim Title2 As String = rs.GetString("product_name")
                       'get all other fields
                        CLV.AddItem(...)
                   Else
                      'only one item left for the last row.
                   End If
Loop
            rs.Close
 
Upvote 0
Top