B4J Question How to get the "Value" in ListView?

JOTHA

Well-Known Member
Licensed User
Hello community,

in B4A ListView is a function called "AddSingleLine2" ...
B4X:
ListView1.AddSingleLine2("Sunday", 1)
... where "Sunday" shows the information to click and after the comma there is a Value (1) for example to get an ID-Number of the dataset.

This function is not in B4J.

How to get such a "Value" in ListView in B4J?
 
Last edited:

JOTHA

Well-Known Member
Licensed User
Hi Enrique Gonzalez R,
thank you for your answer:
Yourlistview.items
I don't need to get an Index ...
I know how to add items to my ListView (1) Add ... or (2) AddAll

The data is coming from SQLite, but with Add i'll get just one item with information and with AddAll i'll get many items.
B4X:
    Private ResultSet1 As ResultSet
    ResultSet1 = SQL1.ExecQuery("SELECT * FROM Data")
    Do While ResultSet1.NextRow
        Layout_009_ListView_001.Items.AddAll(Array As String(""&ResultSet1.GetString("AGD_001")&"", ""&ResultSet1.GetString("AGD_030")&""))
    Loop
... but i want to get some information like ListView in B4A or like a map (i mean like key + value in a map)

The solution should be "getting a value after clicking into the ListView" ... means:
The ListView shows ResultSet1.GetString("AGD_001") and when i do a mouseclick into the ListView i'll get the value of ResultSet1.GetString("AGD_030")
 

Enrique Gonzalez R

Well-Known Member
Licensed User
Okey i get it.

I usually use another list that has the same index as the one i used to fill the listview
 

Harris

Expert
Licensed User
Use xCustomListView. A B4X component across all platforms.

Yes, it does means some refactoring, but you will be much better off for it in the long run (if you plan to support it).

Think - B4X - XUI - and fully support all your projects (A,J,i) with same source.
What more can one ask for? Erel has gone to great lengths to implement this and ensure it works.

To code (from this point on) in separate A, J, i is futile and will lead to your question(s) and more coding (support) on your part.

In fact, as I have stated in many posts - xCLV is your best friend - embrace it - then sit back and relax - amazed at what you have accomplished with little effort.

Thanks

PS: I would strongly advise others NOT encourage anything other than B4X / XUI since this is a step backwards and likely will be deprecated and no longer supported in the future. Move on and reap the rewards of progress.
 
Last edited:

JOTHA

Well-Known Member
Licensed User
Hello Harris,
this is the solution!
Use xCustomListView. A B4X component across all platforms.
I use it in B4A also and it works very good!

Thank you for pointing me in the right direction!
 
Top