Creo una lista variables de un tipo propio, la grabo con File.WriteList y luego cuado la recupero con File.ReadList me da un error cuando accedo a un elemento de la lista.
¿Que hago mal?
¿Que hago mal?
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim DatosInternet As List
Type DatoInternet(D As Int, ID As String, Indice As Int, Texto As String)
Dim B, BL As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
b.Initialize("B")
b.Text="Write"
Activity.AddView(b,10,10,100,40)
BL.Initialize("Bl")
BL.Text="read"
Activity.AddView(BL,120,10,100,40)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub B_Click
Dim l As Int
Dim miLista As List
miLista.Initialize
For l=1 To 10
Dim Dato As DatoInternet
Dato.Initialize
Dato.D=l
Dato.ID=NumberFormat(l,3,0)
Dato.Indice=l*10
Dato.Texto="Hola"
miLista.Add( Dato)
Next
File.WriteList(File.DirRootExternal,"Lista",miLista)
End Sub
Sub BL_Click
Dim l As Int
Dim miLista As List
miLista=File.ReadList(File.DirRootExternal,"Lista")
For l=1 To miLista.Size-1
Dim Dato As DatoInternet
Dato=miLista.Get(l) ' da error
Log(Dato.d)
Next
End Sub