SQLLite to ListView and selection

artiechappie

Member
Licensed User
Hi Guys,

Hope someone can help me here as part of my app populates a ListView based on an SQL query. The ListView contains the info that the user needs and based on ther selection I then need to pull other data from the SQLLite database to move the process further.

OK - here's my problem. All I can get form the ListView when the selection is made is either: The position value of the selection as a number or a Java string, neither of which helps al lot. If I could get the string back then I could use part of the string to do a lookup in the table.

Here's my code snippet:

B4X:
' This part populates the ListView

DBUtils.ExecuteListView(SQL, "Select [Description] || ' ' || [Dimensions] || ' Max. Lines: ' || [Maxlines] from MyTable WHERE Category == 'Home'", Null, 0, ProductSelector, False)

' Set up the ListView

ProductSelector.Visible = True
Activity.Title = "Choose your product"
   
ProductSelector.SingleLineLayout.ItemHeight = 75dip
ProductSelector.SingleLineLayout.Label.TextSize = 18
ProductSelector.SingleLineLayout.Label.TextColor = Colors.White
ProductSelector.SingleLineLayout.Label.Gravity = Gravity.LEFT

Sub ProductSelector_ItemClick (Position As Int, Value As Object)   

Msgbox("You chose as value", Value)

Msgbox("You chose as position", Position)
    
End Sub

In this case, Position will return the value of the actual position as a number in the ListView, but Value returns [Ljava.lang.string@462fe240 instead of the actual string.

Any ideas as to how I can retrieve the actual string value in the ListView.

Thanks
 
Last edited:

Ennesima77

Member
Licensed User
Hi,
I have the same problem of artiechappie, what king of variable do you declare?
Can you post some code to take an idea?

thanks a lot.
 
Upvote 0
Top