Android Question List and array's

G-ShadoW

Active Member
Licensed User
Longtime User
Hello,

how to replace position in all lines

example:
yyyyy;xxxxx;1;0;0;0

I need to replace y and x to look like this

xxxxx;yyyyy;1;0 last 2 value's delete
 

DonManfred

Expert
Licensed User
Longtime User
read the lines
for each lines....
get line x
split it with regex into the parts
create the line new
write the new line
next

write back all lines
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
B4X:
For i=0 To MyList.Size-1
      Dim MyLine As String =MyList.Get(i)
     
        Dim arrLine() As String = Regex.Split(",",MyLine)
   
     
    Next

how to get x ?
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
B4X:
Dim x As String
   Dim y As String

   For i=0 To MyList.Size-1
    Dim MyLine As String =MyList.Get(i)
  
    Dim arrLine() As String = Regex.Split(",",MyLine)
    x = arrLine(1)
     y= arrLine(0)
    Log("X line: " & x)
     Log("Y line: " & y)
   Next
  Log(MyLine)
End Sub

how to save it back ?
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
uppsss, I get error on saving ?

B4X:
Dim x As String
    Dim y As String
    Dim b As String
  
  
    For i=0 To MyList.Size-1
      Dim MyLine As String =MyList.Get(i)
    
        Dim arrLine() As String = Regex.Split(",",MyLine)
        x = arrLine(1)
        y = arrLine(0)
        b = arrLine(3)
        ListView1.AddSingleLine(x & ";" & y & ";" & b)
    Next
File.WriteList(File.DirRootExternal , "/cr/au.txt", ListView1)
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
This works now

B4X:
Dim x As String
    Dim y As String
    Dim b As String
    Dim d As String
    For i=0 To MyList.Size-1
      Dim MyLine As String =MyList.Get(i)
    
        Dim arrLine() As String = Regex.Split(",",MyLine)
        x = arrLine(1)
        y = arrLine(0)
        b = arrLine(3)
        d= x & ";" & y & ";" & b
        ListView1.AddSingleLine(x & ";" & y & ";" & b)
    myline2.Add(d)
    Next
File.Writelist(File.DirRootExternal , "/cr/au.txt", myline2)
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Nice one Shadow, glad your finding your feet. Don't forget the power of the Log command when trying to debug code, i.e .
B4X:
Log("(0)= " & arrLine(0) & " (1)= " & arrLine(1))
To see what values you actually have when connected in debug mode.
 
Upvote 0
Top