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

Discussion in 'B4J Questions' started by JOTHA, May 26, 2019.

  1. JOTHA

    JOTHA Well-Known Member Licensed User

    Hello community,

    in B4A ListView is a function called "AddSingleLine2" ...
    Code:
    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: May 26, 2019
  2. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    Use

    Yourlistview.items

    You can add or get ítem you are looking for with .add or .get
     
  3. JOTHA

    JOTHA Well-Known Member Licensed User

    Hi Enrique Gonzalez R,
    thank you for your answer:
    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.
    Code:
    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")
     
  4. Enrique Gonzalez R

    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
     
  5. Harris

    Harris Well-Known Member 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: May 27, 2019
    j_o_h_n, Erel, JOTHA and 1 other person like this.
  6. JOTHA

    JOTHA Well-Known Member Licensed User

    Hello Harris,
    this is the solution!
    I use it in B4A also and it works very good!

    Thank you for pointing me in the right direction!
     
    Harris likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice