Data from ListView into List

Omar

Member
Licensed User
Longtime User
Hello,

I want to confirm what is the best way to transfer data from ListView into a List, for example if I use this code:


B4X:
      Dim ListView1 as ListView
                Dim NumList As List

                'Load data into ListView1      

      NumList = ListView1

Would NumList obtain all the data from ListView1?

Thank you.
 

kickaha

Well-Known Member
Licensed User
Longtime User
No, you would get an error as you are trying to assign a ListView type to a list. You would have to have a loop and get each item :
B4X:
For i = 0 To ListView1.Size
NumList.Add (ListView1.GetItem (i))
Next

Or much simpler is to add/remove the item from the list at the same time you add/remove it from the ListView.
 
Upvote 0

Omar

Member
Licensed User
Longtime User
No, you would get an error as you are trying to assign a ListView type to a list. You would have to have a loop and get each item :
B4X:
For i = 0 To ListView1.Size
NumList.Add (ListView1.GetItem (i))
Next

Or much simpler is to add/remove the item from the list at the same time you add/remove it from the ListView.


Thank you kickaha!

Actually I was thinking of the loop but tried the direct NumList = ListView1 first a short while ago and for some reason it compiled fine and also ran ok on my device without giving any error but I had a feeling that this was not a good approach.

Thanks for your help.
 
Upvote 0
Top