looping through a listview and writing to file

lawboy

Member
Licensed User
Longtime User
Hello, what is the correct way to loop through values in a listview and/or spinner control?

Here is what I have so far but I get an error at the last value:

B4X:
Sub WriteTextWriter            
Dim TextWriter1 As TextWriter
Dim listcount As Int
Dim listvalue As String

            TextWriter1.Initialize(File.OpenOutput(File.DirRootExternal, "listview.txt", False))
   listcount = 0
   listvalue = listview1.GetItem(listcount) 
   
   Do While listvalue <> Null 
   listvalue = listview1.GetItem(listcount)
             TextWriter1.WriteLine(listvalue)
             Msgbox(listvalue ,listcount)   
   listcount = listcount + 1
   Loop
TextWriter1.Close
End Sub

Thanks,
Lawboy
 
Last edited:

lawboy

Member
Licensed User
Longtime User
I figured it out. So, here it is.

B4X:
Sub WriteTextWriter

    Dim TextWriter1 As TextWriter
    TextWriter1.Initialize(File.OpenOutput(File.DirRootExternal, "listview.txt", False))
    
   Dim ListCount As Int
   Dim ListValue As String

   
   ListCount = 0
   ListValue = ListView1.GetItem(ListCount)
   
     Do While ListCount < ListView1.Size
   ListValue = ListView1.GetItem(ListCount)
   TextWriter1.WriteLine(ListValue)
    ListCount = ListCount + 1
   Loop
   TextWriter1.Close

-Lawboy
 
Upvote 0
Top