Android Question [Solved] How to load a ComboBox from a CSV file?

Sergio Castellari

Active Member
Licensed User
Situation:
a) I have a simple file "statuses.csv" that contains the following:
B4X:
01-general
02-ugarte Centro
03-ugarte Rural

b) I want to load it to a ComboBox

Try the following but it doesn't work:

B4X:
Dim su As StringUtils
Dim codTe As List = su.LoadCSV(Main.pRutaBase, "estados.csv", ",")
Log("Tamaño Archivo codte: " & codTe.Size)
Log("Item 0: " & codTe.Get(0))
    For i = 0 To codTe.Size -1
        B4XComboBox1.cmbBox.Add(codTe.Get(i))
        Log("Item: " & i & " --->" & codTe.Get(i))
    Next
 

Sergio Castellari

Active Member
Licensed User
Thanks to an example that I found out there from @LucaMs, I was able to solve it:
B4X:
Dim lstData As List
lstData = File.ReadList(Main.pRutaBase, "estados.csv")
For Each Text As String In lstData
   B4XComboBox1.cmbBox.Add(Text)       
Next

Total thanks
 
Upvote 0

Sergio Castellari

Active Member
Licensed User
Excellent @Mahares !!!
It worked the same way!
Now I have understood that "StringUtils", returns an array for each row / line of the CSV file. In my case, each row has only one field, and therefore you indicate "line (0)". Thanks for teaching me!.
NOTE: I have a "special" file where I am saving valuable source code. These two ways to load a ComboBox go there!

Virtual hugs!
 
Upvote 0
Top