Android Question [SOLVED]Invalid Double error using GetItem in a spinner having a String value

Daniel44

Active Member
Licensed User
Hi everyone!

I'm trying to retrieve some data from a database's table in a spinner whose field is of type "enum" with the values 'A', 'I' and I use a list and a foreach iteration inside a Job to do it, but I get an error "Invalid Double"?? it's a string what I'm trying to retrieve from the database and I don't understand what I'm doing wrong. Thank you very much.

Here's my code:
JobDone:
Case  EDITARXREGISTRO
                Dim ListEdicion As List
                ListEdicion.Initialize
                ListEdicion = parser.NextArray
                For i = 0 To ListEdicion.Size - 1
                 
                    Dim MapaListEdit As Map
                                 
                    MapaListEdit = ListEdicion.Get(i)
                    Log(MapaListEdit)
                 
                Next
             
                For Each colroot As Map In ListEdicion
                 
                    Dim clave As String = colroot.Get("ID")
                    Dim nombre As String = colroot.Get("NOMBRE")
                    Dim estado As String = colroot.Get("ESTADO")
                 
                    Log(clave)
                    Log(nombre)
                    Log(estado)
                 
                
                    txtNombre.Text = nombre
                    spEstado.GetItem(estado)

The Map Log:

B4X:
(MyMap) {ID=2, NOMBRE=MARZO-ABRIL, ESTADO=A}

the Error Log:

B4X:
Error occurred on line: 131 (CAMP)
java.lang.NumberFormatException: Invalid double: "A"
    at java.lang.StringToReal.invalidReal(StringToReal.java:63)
    at java.lang.StringToReal.initialParse(StringToReal.java:164)
    at java.lang.StringToReal.parseDouble(StringToReal.java:282)
    at java.lang.Double.parseDouble(Double.java:301)
    at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:58)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:7406)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Daniel44

Active Member
Licensed User
it expects a double? You are giving a String with the Content A

Hey Don GetItem returns a string Am I wrong? SelectedItem it's read-only and I need modify that value later that's the reason I'm using GetItem but it doesn't work. Thank you for answering
 
Upvote 0

Daniel44

Active Member
Licensed User
Well.. I've changed my code..

B4X:
txtEstado.Text = estado
spEstado.AddAll(Array As String("A","I"))
B4X:
 
Upvote 0
Top