Android Question [SOLVED] insert and read Types into List

Discussion in 'Android Questions' started by makis_best, May 8, 2019.

  1. makis_best

    makis_best Active Member Licensed User

    Hi...

    Can someone give me an example how I can insert a type into a list and how I can read it?

    For example I have the the type "ItemType" and the list "ItemList"

    Code:
    Type ItemType(Code As String, Description As String, Munit As String, Price As Double, Quantity As Double)
    Public TheItem As ItemType
    Public ItemList As List
    How the type can insert into the list?
    How I can read from list a value?

    I can't find anywhere an example about it.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    ItemList.Add(TheItem)
    Dim a As ItemType = ItemList.Get(0)
     
  3. makis_best

    makis_best Active Member Licensed User

    ItemList.Get(0) read all the first item.... what if i want to read only the price of the 3 item?
     
  4. DonManfred

    DonManfred Expert Licensed User

    read the 3. item like erel mentioned.
    Get the price from the custom type
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    ItemList.Add(TheItem)
    Dim a As ItemType = ItemList.Get(0)
    Log(a.Price)
    No "reading" is done. The list hold pointers to the actual objects. You get the object and then access its fields.
     
  6. makis_best

    makis_best Active Member Licensed User

    Done....

    Thank you.
     
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