Here is the code:
The beginning og the log is a log(LocLst) after the file read
The line causing the error:LocTmp = LocLst.Get(x)
I can not figure out why I am getting the cast error?
Bill
B4X:
Sub Process_Globals
Type StrLoc (City As String, State As String, Lat As Double, Lon As Double)
Dim LocLst As List
End Sub
Sub Globals
Private LvLoc As ListView
Dim x As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Sto_Loc")
End Sub
Sub Activity_Resume
LocLst.Initialize
LvLoc.Clear
LvLoc.AddSingleLine("Use GPS for Location")
LvLoc.AddSingleLine("Add New Location")
If File.Exists(File.DirInternal, "StoLoc.Lst") Then
LocLst = File.ReadList(File.DirInternal, "StoLoc.Lst")
Log("LocLst " & LocLst)
For x = 0 To LocLst.Size - 1
Dim LocTmp As StrLoc
LocTmp = LocLst.Get(x)
LvLoc.AddSingleLine(LocTmp.City&", "& LocTmp.State)
Next
End If
The beginning og the log is a log(LocLst) after the file read
B4X:
** Activity (stoloc) Resume **
LocLst (ArrayList) [[City=Paris, State=Texas, Lat=33.6609389, , Lon=-95.555513, IsInitialized=true], [City=Paris, State=Texas, Lat=33.6609389, , Lon=-95.555513, IsInitialized=true], [City=Paris, State=Tennessee, Lat=36.3020023, , Lon=-88.3267107, IsInitialized=true], [City=Paris, State=Illinois, Lat=39.611146, , Lon=-87.6961374, IsInitialized=true], [City=Paris, State=Kentucky, Lat=38.2097987, , Lon=-84.2529869, IsInitialized=true], [City=Clinton, State=Massachusetts, Lat=42.4167635, , Lon=-71.6829081, IsInitialized=true]]
stoloc_activity_resume (java line: 393)
java.lang.ClassCastException: java.lang.String cannot be cast to com.sailawayapps.bestwx.stoloc$_strloc
at com.sailawayapps.bestwx.stoloc._activity_resume(stoloc.java:393)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at com.sailawayapps.bestwx.stoloc$ResumeMessage.run(stoloc.java:298)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: java.lang.String cannot be cast to com.sailawayapps.bestwx.stoloc$_strloc
The line causing the error:LocTmp = LocLst.Get(x)
I can not figure out why I am getting the cast error?
Bill
Last edited: