Android Question Save xCLV with two labels in each item to a text file

mscientist33

Active Member
Licensed User
I have seen a lot of examples of using the xCLV. Most of them have to do with sql databases. I have an xCLV with two labels per item. I already have the location chooser working and all, I don't know how to save each item in the text file. I would like each label to be on the same line separated by a comma. I will also have a button to have the option to load a text file (with two items per line separated by a ,).
 

LucaMs

Expert
Licensed User
Longtime User
Are you using the value associated with each CLV item for other purposes?

If not, create a custom type to hold the 2 values (like: Type tItem(Value1 As String, Value2 As String)), a new tItem variable when you add a new item of the clv and add it as item value.

If yes:
B4X:
    Dim SB As StringBuilder
    SB.Initialize
    Dim Value1, Value2 As String
    For i = 0 To CLV.Size - 1
        Value1 = CLV.GetPanel(i).GetView(ItemIndexOfLabel1).Text
        Value1 = CLV.GetPanel(i).GetView(ItemIndexOfLabel2).Text
        SB.Append($"${Value1},${Value2}${CRLF}"$)
    Next
    File.WriteString(Dir, FileName, SB.ToString)
 
Upvote 1
Top