Android Code Snippet SD: Spinner with CustomView

Star-Dust

Expert
Licensed User
Longtime User
View attachment 67819

This is the problem, the Spinner is in a panel with ScrollView
Ok, so the problem is that.
Positions can not be correctly identified within the scrollView.
To calculate them you must also know the position of the panel inside the scrollview. He only calculates the position of the ScrollView within the activity.
 

Star-Dust

Expert
Licensed User
Longtime User
Make the Left and Top variables available at the beginning of DesignerCreateView and edit them from code.
 

Star-Dust

Expert
Licensed User
Longtime User
Last edited:

Daniel Konstantinidis

New Member
Licensed User
Hello, I am new in B4A.
I like your library but I am having some problems implementing it in my project:


Logger connected to: motorola Moto E (4) Plus
--------- beginning of crash
--------- beginning of main
Copying updated assets files (6)
*** Service (starter) Create ***
--------- beginning of system
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (pelatesdetails) Create, isFirst = true **
Errore
Error occurred on line: 0 (SD_Spinner)
java.lang.RuntimeException: Object should first be initialized (View).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at b4a.example.sd_spinner._designercreateview(sd_spinner.java:632)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
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.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:61)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.TabHostWrapper.createPanelForLayoutFile(TabHostWrapper.java:117)
at anywheresoftware.b4a.objects.TabHostWrapper.AddTabWithIcon(TabHostWrapper.java:160)
at b4a.example.pelatesdetails._configurarcontroles(pelatesdetails.java:397)
at b4a.example.pelatesdetails._activity_create(pelatesdetails.java:366)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
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 b4a.example.pelatesdetails.afterFirstLayout(pelatesdetails.java:104)
at b4a.example.pelatesdetails.access$000(pelatesdetails.java:17)
at b4a.example.pelatesdetails$WaitForLayout.run(pelatesdetails.java:82)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
** Activity (pelatesdetails) Resume **
 

Star-Dust

Expert
Licensed User
Longtime User
The error indicates that it has not been initialized.
Show the code where you state, initialize and use the Spinner class.
 

Star-Dust

Expert
Licensed User
Longtime User
To enter a code you must put it in here

It seems you did not initialize them Spinner.
Did you include the Spinner in Design?
Have you seen my example?
 

Daniel Konstantinidis

New Member
Licensed User
Thank you about telling me the way to put a code, I didn't know how.
1)Yes I did include the Spinner in Design.
2)I am trying to reproduce your example.

May be the fact that I am implementing the spinner inside a TabHost matters?
 

Star-Dust

Expert
Licensed User
Longtime User
2)I am trying to reproduce your example.
I think not, but I see your code is very messy.

Try a standar spinner and see if it generates an error.

I make your code call a function of the Spinner Class when isn't initialized.
I see that you receive data from the internet and at some point close and reopen an activity (what is wrong).
They seem not very clear things
 
Last edited:

Daniel Konstantinidis

New Member
Licensed User
If this helps, this is the errors I get after debuging my app :
B4X:
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (pelatesdetails) Create, isFirst = true **
Error occurred on line: 59 (SD_Spinner)
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams
    at anywheresoftware.b4a.objects.ViewWrapper.getLeft(ViewWrapper.java:162)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:352)
    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.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:61)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at anywheresoftware.b4a.objects.TabHostWrapper.createPanelForLayoutFile(TabHostWrapper.java:117)
    at anywheresoftware.b4a.objects.TabHostWrapper.AddTabWithIcon(TabHostWrapper.java:160)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    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 b4a.example.pelatesdetails.afterFirstLayout(pelatesdetails.java:104)
    at b4a.example.pelatesdetails.access$000(pelatesdetails.java:17)
    at b4a.example.pelatesdetails$WaitForLayout.run(pelatesdetails.java:82)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6339)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
 

Star-Dust

Expert
Licensed User
Longtime User
Say you are assigning a type of type seen a value or a variable of other type. Check the line 59
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…