Android Question Androidspinner wheel

Liew

Member
Licensed User
Longtime User
Hi Erel,
May I know whether the spinner wheel libraries as shown by below link can be supported by b4x.
https://www.b4x.com/android/forum/threads/62723/#content
I had tried to create a designer file with adding this spinner custom wheel, it is produced compilation errors.
Error log:
Copying updated assets files (2)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** cc: B4XPage_Created
Run page2
Error occurred on line: 20 (nextconf)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1068)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:425)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:245)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:259)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:165)
    at b4a.example.main._activity_create(main.java:415)
    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:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8810)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 25 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 26 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1068)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:262)
    at b4a.example.b4xpages._addpageandcreate(b4xpages.java:29)
    at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:59)
    ... 28 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 34 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 35 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:329)
    at b4a.example.nextconf._b4xpage_created(nextconf.java:75)
    ... 37 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:147)
    ... 40 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:251)
    at android.content.res.Resources.getDrawableForDensity(Resources.java:1050)
    at android.content.res.Resources.getDrawable(Resources.java:990)
    at android.content.res.Resources.getDrawable(Resources.java:965)
    at androidspinnerwheelwrapper.androidHorizontalWheelWrapper.updateSpinner(androidHorizontalWheelWrapper.java:103)
    at androidspinnerwheelwrapper.androidHorizontalWheelWrapper.setupSpinnerWheel(androidHorizontalWheelWrapper.java:90)
    at androidspinnerwheelwrapper.androidHorizontalWheelWrapper._initialize(androidHorizontalWheelWrapper.java:65)
    ... 43 more
Message longer than Log limit (4000). Message was truncated.
** Activity (main) Resume **

Does it mean that B4a written libraries will not work on B4X?
Please reply.

Thanks
 

mangojack

Expert
Licensed User
Longtime User
This might be a more up to date alternative... And also cross platform

 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Erel,
May I know whether the spinner wheel libraries as shown by below link can be supported by b4x.
https://www.b4x.com/android/forum/threads/62723/#content
I had tried to create a designer file with adding this spinner custom wheel, it is produced compilation errors.
Error log:
Copying updated assets files (2)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** cc: B4XPage_Created
Run page2
Error occurred on line: 20 (nextconf)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1068)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:425)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:245)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:259)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:165)
    at b4a.example.main._activity_create(main.java:415)
    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:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8810)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 25 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 26 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1068)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:262)
    at b4a.example.b4xpages._addpageandcreate(b4xpages.java:29)
    at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:59)
    ... 28 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 34 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 35 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:329)
    at b4a.example.nextconf._b4xpage_created(nextconf.java:75)
    ... 37 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:147)
    ... 40 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:251)
    at android.content.res.Resources.getDrawableForDensity(Resources.java:1050)
    at android.content.res.Resources.getDrawable(Resources.java:990)
    at android.content.res.Resources.getDrawable(Resources.java:965)
    at androidspinnerwheelwrapper.androidHorizontalWheelWrapper.updateSpinner(androidHorizontalWheelWrapper.java:103)
    at androidspinnerwheelwrapper.androidHorizontalWheelWrapper.setupSpinnerWheel(androidHorizontalWheelWrapper.java:90)
    at androidspinnerwheelwrapper.androidHorizontalWheelWrapper._initialize(androidHorizontalWheelWrapper.java:65)
    ... 43 more
Message longer than Log limit (4000). Message was truncated.
** Activity (main) Resume **

Does it mean that B4a written libraries will not work on B4X?
Please reply.

Thanks
You are missing the resources in the /Objects/res folder....me thinks. Make sure they are there
 
Upvote 0

Liew

Member
Licensed User
Longtime User
You are missing the resources in the /Objects/res folder....me thinks. Make sure they are there
Hi Johan,
I think the Objects/res folder files are automatically generated during compilation and we only required to put your library files
a) AndroidSpinnerWheel.jar
b) AndroidSpinnerWheel.xml
into the B4 libraries search folder for it to work.
Your library works well on B4A platform. But once I tried to use it in B4xpages, it seems that it is not recognized and produce lots of errors.
Thanks.
Regards,
Liew
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan,
I think the Objects/res folder files are automatically generated during compilation and we only required to put your library files
a) AndroidSpinnerWheel.jar
b) AndroidSpinnerWheel.xml
into the B4 libraries search folder for it to work.
Your library works well on B4A platform. But once I tried to use it in B4xpages, it seems that it is not recognized and produce lots of errors.
Thanks.
Regards,
Liew
See this post in that thread.


When you unzip the original project that I posted, check the Objects/res folder before you run it. Those files in the various Objects/res/xxx folders must be set to READ only else they will be deleted on the very first compile of the project. You need to copy those resources to your B4XPages project and make sure they are set to READ ONLY
 
Upvote 0

Liew

Member
Licensed User
Longtime User
See this post in that thread.


When you unzip the original project that I posted, check the Objects/res folder before you run it. Those files in the various Objects/res/xxx folders must be set to READ only else they will be deleted on the very first compile of the project. You need to copy those resources to your B4XPages project and make sure they are set to READ ONLY
Hi Johan,
Thanks a lot for replying to my message.
I had tried to put those res files into the new project under B4x, it just never recognise the wheelspinner library.
Once I simply create a spinnerwheel (custom view) view using Designer view, the project will not work.
It will work well in B4a pages but not B4X pages.
Perhaps if you have some time try to post a sample project in B4x.
Thanks.
Regards,
Liew
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan,
Thanks a lot for replying to my message.
I had tried to put those res files into the new project under B4x, it just never recognise the wheelspinner library.
Once I simply create a spinnerwheel (custom view) view using Designer view, the project will not work.
It will work well in B4a pages but not B4X pages.
Perhaps if you have some time try to post a sample project in B4x.
Thanks.
Regards,
Liew
Run attached project....

1.png


I have moved the Library resources to a folder called "LibRes" that is on the same folder level as the /Files folder of the B4XPages project.

Note the below in the Main module of the project:

#AdditionalRes:..\LibRes:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\LibRes

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Code in B4XMainPage:

Code in B4XMainPage:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Login")
    Page2.Initialize
    B4XPages.AddPage("Page 2", Page2)
    Page3.Initialize
    B4XPages.AddPage("Page 3", Page3)
   
    vsw1.ItemDimmedAlpha = 100
    vsw1.SpinnerTextColor = Colors.Red
    vsw1.SpinnerTextSize = 15
    months = Array As String("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
    vsw1.SpinnerItems = months
    vsw1.setupSpinnerWheel
    vsw1.SelectedIndex = 6
   
   
    countries = Array As String(" USA ", " Canada ", " Ukraine ", " France ", " South Africa ", " Germany ", " Scotland ", " United Kingdom ", " Russia ", " Israel ", " Brazil ", " Ireland ", " China ")
    'The following array is populated with the names of the image files in the /Object/res/drawable folder
    'It must have the same number of elements as the "countries" array in the above statement
    vsw2.Images = Array As String("usa","canada", "ukraine", "france", "southafrica", "germany", "scotland", "unitedkingdom", "russia", "israel", "brazil", "ireland", "china")
    vsw2.SpinnerItems = countries
    vsw2.SpinnerTextColor = Colors.Cyan
    vsw2.SpinnerTextSize = 20
    vsw2.setupSpinnerWheel
    vsw2.SelectedIndex = 2

End Sub

Also note the files (flags) in the /Files folder and them having been added to the Files tab of the IDE

It will only work with Android - not B4J or B4I. For the latter you need to use or create a B4X Custom View.

I have attached a zip with the B4A library files (jar and xml). Extract and copy them to your additional library folder
 

Attachments

  • B4XMainPage.zip
    127.8 KB · Views: 156
  • AndroidSpinnerWheel_V1_01.zip
    50.9 KB · Views: 147
Last edited:
Upvote 0

Liew

Member
Licensed User
Longtime User
Hi Johan,
A big thank you for posting me the example in b4x. I had tested it works very well with my existing project by putting the resources file into the additional resources folder.
May I ask the reason of doing so.
1) Is it because the library that was created by b4a is not compatible with b4x format?
2) Any other old library previously running with b4a should adopt this strategy?
Regards,
Liew
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan,
A big thank you for posting me the example in b4x. I had tested it works very well with my existing project by putting the resources file into the additional resources folder.
May I ask the reason of doing so.
1) Is it because the library that was created by b4a is not compatible with b4x format?
2) Any other old library previously running with b4a should adopt this strategy?
Regards,
Liew
Not at all - the resources can either be in the /Objects/res folder (must be set to READ ONLY) or in a folder on the same folder level as the /Files & /Objects folder of the B4A project (the latter case does not require it to be set to READ ONLY)

When in the /Objects/res/xxx folders the files will be deleted upon first compile if not set to READ ONLY. So, when downloading a project with resources in the /Objects/res/xxx folders you need to ensure (after unzipping the B4A project) that the files in those folders are set to READ ONLY or else they will be deleted upon first compile of the B4A project. Really no adaption required for using it in B4X pages - I have done the mod just so that you don't have the resources deleted when you compile it the first time.
 
Upvote 0

Liew

Member
Licensed User
Longtime User
Not at all - the resources can either be in the /Objects/res folder (must be set to READ ONLY) or in a folder on the same folder level as the /Files & /Objects folder of the B4A project (the latter case does not require it to be set to READ ONLY)

When in the /Objects/res/xxx folders the files will be deleted upon first compile if not set to READ ONLY. So, when downloading a project with resources in the /Objects/res/xxx folders you need to ensure (after unzipping the B4A project) that the files in those folders are set to READ ONLY or else they will be deleted upon first compile of the B4A project. Really no adaption required for using it in B4X pages - I have done the mod just so that you don't have the resources deleted when you compile it the first time.
Hi Johan,

I only realized now that your example actually bundled with the resources file such as wheel_bg_hor.xml, divider_dark_gradient_horizontal.xml etc within the object/res/... besides the library file.
I thought those was generated by the compiler and I am really ignorant about its existence.
Never really knows that you had put on so much effort to get the wheelspinner to work.
Thanks again.
Regards,
Liew
 
Upvote 0
Top