Android Question add new data to existing data array in list

mrossen

Active Member
Licensed User
Longtime User
Hi,

I have a multicolum dataset I read into at list.

I dont use all the records in listview, there fore I have the problem finding it again.
The listview position is not the same as in the list.

My plan was to add the position of the listview to the existing list.

But it har to be done at the end of the recordline.

How can I do that?

B4X:
If Job.Success Then
    Dim res As String
        res = Job.GetString
   
        Dim parser As JSONParser
        parser.Initialize(res)
        Select Job.JobName
            Case brand
           
                brand_list = parser.NextArray 'returns a list with maps
               
                For i = 0 To brand_list.Size - 1
                    m = brand_list.Get(i)
                   
                    tl.First = m.Get("brand") & " "  & m.Get("model") & " / " & m.Get("engine") & " / " & m.Get("yearfrom")
                    tl.Second = m.Get("fuel")  & " - " & m.Get("variant") & " - " & m.Get("comments")
                   
                    newData = m.Get("brand") & " - " & m.Get("model") & " - " & m.Get("engine") & " - " & m.Get("yearfrom") & " - " & m.Get("fuel") & " - " & m.Get("variant")
                   
                    If newData <> oldData Then
                        ListViewCars.AddTwoLines2(tl.First, tl.Second, tl)
                        brand_list.
                    End If
                       
                    oldData = m.Get("brand") & " - " & m.Get("model") & " - " & m.Get("engine") & " - " & m.Get("yearfrom") & " - " & m.Get("fuel") & " - " & m.Get("variant")
                   
                Next
               
               
        End Select
    Else
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
 

DonManfred

Expert
Licensed User
Longtime User
Use a global list to hold the actual contents of brands
When filling the listview: clear global list on start. For each item you add to the listview you add the corresponsing map to the global list.
B4X:
For i = 0 To brand_list.Size - 1
  dim m as Map = brand_list.Get(i)
and then add "m" to the globallist

Now it should be easier to find the right id and in addition you have found the hole map for this entry.
 
Upvote 0
Top