Android Question Problem initializing a Spinner

mrjaw

Active Member
Licensed User
Longtime User
Hi!
I am using a spinner declared with designer so I never initalize this becuase "designer 's object must not be initialize" but when I run my code I get an error ask me initialize the spinner
This is my code

B4X:
Sub Globals
    Dim Sconcepto As Spinner

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")
   
    Activity.LoadLayout("FrmVisita")
    Log("Creando la actividad")

    LoadConceptos
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
'
'==============================
Sub LoadConceptos
  Dim param As String
  Dim JobBuscar As HttpJob
  '
  JobBuscar.Initialize("JobBuscar", Me)
      '       
      param= "getconceptosvisitas/" & Main.Pre.Token
      '
      Main.url2 = Main.Urlserver & param
      JobBuscar.Download(Main.url2)
End Sub

Sub JobDone (Job As HttpJob)
    Dim res As String
    Log(" Dentro de JobDone " )
    '
    If Job.Success = True Then
        '
        res = Job.GetString       
        Log("res::" & res)
               
        '
        Select Job.JobName
            Case "JobBuscar"
                '
                Log("Response from server: " & res)
                Dim parser As JSONParser
                '
                parser.Initialize(res)
                '   
                'Sconcepto.ini
                Dim LISTA As List
                LISTA = parser.NextArray 'returns a list with maps
                Sconcepto.AddAll(LISTA)
               
'                For i = 0 To LISTA.Size - 1
'                    Dim m As Map
'                    m = LISTA.Get(i)
'                    '-----Agregando a la tabla-------
'                    Name =  m.Get("f_conceptos")         
'                    Sconcepto.Add(Name)
'                Next
           
            Case "JobSave"

        End Select
        '
    Else   
        libcode.DialogAviso("No conexion")
       
    End If
    Job.Release
End Sub


Sub Sconceptos_ItemClick (Position As Int, Value As Object)
    Dim seleccion As String
    seleccion=Sconcepto.SelectedItem
    '
End Sub

I am getting this error ...
B4X:
visitas_jobdone (B4A line: 94)
Sconcepto.AddAll(LISTA)
java.lang.RuntimeException: Object should first be initialized (Spinner).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
    at anywheresoftware.b4a.objects.SpinnerWrapper.AddAll(SpinnerWrapper.java:119)
    at b4a.example.visitas._jobdone(visitas.java:458)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.keywords.Common$4.run(Common.java:930)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3687)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Object should first be initialized (Spinner).

I dont know where is the error and why it asks me for initialize spinner


Any cluees?
 

mrjaw

Active Member
Licensed User
Longtime User
I solved! The problema was the name in the form was not equal to declaration.

Thks
 
Upvote 0
Top