Need advice, http repsonse to listview

vinny

Member
Licensed User
Longtime User
I could use a bit of direction. I have a web service that returns records like csv format. I'd like to put these lines into a list view but I'm not sure what approach to take with b4a. Is there a way to stream into a map object? Should I load into a text file first then read the lines? The web service can be altered to get the best output for b4a.

Thank you in advance,

Vince
 

vinny

Member
Licensed User
Longtime User
Making the file is easy, and loading the listview is easy but I can't get the list made right. Here is my code:

Dim objSU As StringUtils
Dim objTable As List
objtable=objSU.LoadCSV(File.DirRootExternal,"LDTimesheetCompanies.txt","|")

lvCompanies.Initialize("lvCompanies")

For i = 0 To objtable.Size -1
lvCompanies.AddSingleLine(objtable.Get(i))
Next
Activity.AddView(lvCompanies, 0, 0, 100%x, 100%y)

I get this in each listview row:
java.lang.String;@45d5f2d0

The text file contains this:
A|B|C|D|E

Also, is there a way to make each row a name/value pair? Do you use a map object for this?
 
Last edited:
Upvote 0

Djembefola

Active Member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim objSU As StringUtils
Dim objTable As List
Dim s() As String
Dim i,ii As Int
objtable=objsu.LoadCSV(File.DirRootExternal,"test.txt","|")
lvCompanies.Initialize("lvCompanies")
For i = 0 To objtable.size -1
  s=objTable.get(i)
  For ii = 0 To s.Length-1
    lvCompanies.AddSingleLine(s(ii))
  Next
Next
Activity.AddView(lvCompanies, 0, 0, 100%x, 100%y)
End Sub
 
Last edited:
Upvote 0

Djembefola

Active Member
Licensed User
Longtime User
Hi Vinny,

s() is not undeclared:

Dim s() as String

Did you try to run the code? It works and shows
A
B
C
D
E
in the Listview.
 
Upvote 0
Top