Android Question How to get text in customlistview?

Chris Guanzon

Active Member
Licensed User
Hi, how can i get the text (string) in customlistview? I can only get the index but not the text. thanks
 

Chris Guanzon

Active Member
Licensed User
Yes, i want to use the value to get the data i need.

B4X:
CustomListView1.Clear
For Each colroot As String In root
     CustomListView1.AddTextItem(colroot,"")
Next
 

Chris Guanzon

Active Member
Licensed User
Another question, how can i get the text for this code? is it the same?

B4X:
CustomListView2.Clear
For Each colroot As Map In root
    Dim product_code As String = colroot.Get("product_code")
    Dim product_name As String = colroot.Get("product_name")
                
    CustomListView1.Add(CREATE_LISTITEMS(product_name,product_code,CustomListView1.AsView.Width,60dip),colroot)
Next
 

Chris Guanzon

Active Member
Licensed User
I want to get the text (string) in "product_name" and "product_code" if i click the item in customlistview.

B4X:
Sub CREATE_LISTITEMS(ProductName As String, ProductCode As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    'we need to add the panel to a parent to set its dimensions. It will be removed after the layout is loaded.
    Activity.AddView(p, 0, 0, Width, Height)
    p.LoadLayout("eloading_transact_cell_items")
    p.RemoveView
    'label1 and button1 will point to the last added views.
    
    lblProductCode.Text = ProductCode
    lblProductName.Text = ProductName
    
    Return p
End Sub
B4X:
            JsonString = API.Connection.GetString
            Dim parser As JSONParser
            parser.Initialize(JsonString)
            Dim root As List = parser.NextArray
           
            CustomListView2.Clear
            For Each colroot As Map In root
                Dim product_code As String = colroot.Get("product_code")
                Dim product_name As String = colroot.Get("product_name")
               
                CustomListView2.Add(CREATE_LISTITEMS(product_name,product_code,CustomListView2.AsView.Width,60dip),colroot)
            Next
 
Top