Android Question List and array's

G-ShadoW

Active Member
Licensed 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
 

G-ShadoW

Active Member
Licensed 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 ?
 

G-ShadoW

Active Member
Licensed 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 ?
 

G-ShadoW

Active Member
Licensed 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)
 

G-ShadoW

Active Member
Licensed 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)
 

RandomCoder

Well-Known Member
Licensed 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.
 
Top