DBUtils and ListView

HengeDK

Member
Licensed User
Longtime User
I have populated a listview with
B4X:
DBUtils.ExecuteListView(SQL, "Select * from news",Null, 0, ListNews, True)
How can I get a return value from listview that I can use for selecting the
current record in item_click

thanks
 

klaus

Expert
Licensed User
Longtime User
When you click on an item in the ListView the Value object returned contains a string array with the content of the whole row with all the colums according to the query.
In your case with SELECT * FROM you get the whole row (all columns) in return.

Best regards.
 
Upvote 0

HengeDK

Member
Licensed User
Longtime User
Thanks for your reply
What do you suggest I do then ?
I want to get the value of colum story in that table
can I use listview.AddTwoLines2 with dbutils.executelistview ?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
It depends on what you want to show and what other value you want to use.
In this example:
DBUtils.ExecuteListView(SQL, "SELECT ColX, ColY, ColID FROM news",Null, 0, ListNews, True)
ColX and ColY will be displayed in the ListView.
When clicking on an item in ListNews, you get in
B4X:
Sub ListNews_ItemClick (Position As Int, Value As Object)
    Dim cols() as String
    Dim ID As Int
    cols = Value
    ' cols(0) -> content of ColX
    ' cols(1) -> content of ColY
    ID = cols(2)  ' content of ColID
Best regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…