O Omar Member Licensed User Longtime User Jun 27, 2011 #1 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.
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.
K kickaha Well-Known Member Licensed User Longtime User Jun 27, 2011 #2 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
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.
O Omar Member Licensed User Longtime User Jun 27, 2011 #3 kickaha said: 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. Click to expand... 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
kickaha said: 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. Click to expand... 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.