B4A Library Spinner Wheel - Vertical and Horizontal (24 June: new lib files in post #47)

It wraps the Vertical Spinner Wheel part of this Github project. Spin the wheel with a finger - up or down. The spinner is cyclic i.e it acts like a circular buffer.

Posting:
1. B4A project demonstrating the use of the Vertical Spinner Wheel - b4aAndroidSpinnerWheel.zip
2. Zipped files with the required library files (including nineoldandroids) - copy them to your additional library folder. Library files are in AndroidSpinnerWheel.zip

Please note: have added no code in the designer or in the B4A project to position the views - just plonked down and dragged them in the designer. Leaving positioning to those making use of this project.

I will add the Horizontal Spinner Wheel part of the project at some stage...

1.png


Sample code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: AndroidSpinnerWheel
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

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

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private vsw1, vsw2 As WheelVerticalView
    Dim months() As String
    Dim cities() As String
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("main")
 
    vsw1.ItemDimmedAlpha = 100
    vsw1.SpinnerTextColor = Colors.Red
    vsw1.SpinnerTextSize = 18
    months = Array As String("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
    vsw1.SpinnerItems = months
    vsw1.setupSpinnerWheel
 
    vsw2.ItemDimmedAlpha = 150
    vsw2.SpinnerTextColor = Colors.Yellow
    vsw2.SpinnerTextSize = 23 
    cities = Array As String("New York", "Washington", "Chicago", "Atlanta", "Orlando", "Los Angeles", "Houston", "New Orleans") 
    vsw2.SpinnerItems = cities
    vsw2.setupSpinnerWheel
 
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub vsw1_value_changed(index As Int)
 
    Log("Selected Month = " & months(index))
 
End Sub

Sub vsw2_value_changed(index As Int)
 
    Log("Selected City = " & cities(index))
 
End Sub

The library:

AndroidSpinnerWheel
Author:
Github: Dimitri Fedorov; Wrapped by: Johan Schoeman
Version: 1
WheelVerticalView
Events:

  • value_changed (index as Int )
Fields:
  • ba As BA
Methods:
  • BringToFront
  • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
  • Initialize (EventName As String)
  • Invalidate
  • Invalidate2 (arg0 As Rect)
  • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
  • IsInitialized As Boolean
  • RemoveView
  • RequestFocus As Boolean
  • SendToBack
  • SetBackgroundImage (arg0 As Bitmap)
  • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
  • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
  • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
  • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
  • setupSpinnerWheel
Properties:
  • Background As Drawable
  • Color As Int [write only]
  • Enabled As Boolean
  • Height As Int
  • ItemDimmedAlpha As Int [write only]
  • Left As Int
  • SpinnerItems() As String [write only]
  • SpinnerTextColor As Int [write only]
  • SpinnerTextSize As Int [write only]
  • Tag As Object
  • Top As Int
  • Visible As Boolean
  • Width As Int

 

Attachments

  • AndroidSpinnerWheel.zip
    132.4 KB · Views: 1,088
  • b4aAndroidSpinnerWheel.zip
    11.4 KB · Views: 1,050
Last edited:

suha

Member
Licensed User
Longtime User
Thanks.


** Activity (main) Pause, UserClosed = false **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 36 (Main)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:208)
at JHS.AndroidSpinnerWheel.main._activity_create(main.java:360)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at JHS.AndroidSpinnerWheel.main.afterFirstLayout(main.java:102)
at JHS.AndroidSpinnerWheel.main.access$000(main.java:17)
at JHS.AndroidSpinnerWheel.main$WaitForLayout.run(main.java:80)
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:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
... 22 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1123)
at android.content.res.Resources.getDrawable(Resources.java:698)
at androidspinnerwheelwrapper.androidVerticalWheelWrapper.updateSpinner(androidVerticalWheelWrapper.java:103)
at androidspinnerwheelwrapper.androidVerticalWheelWrapper.setupSpinnerWheel(androidVerticalWheelWrapper.java:90)
at androidspinnerwheelwrapper.androidVerticalWheelWrapper._initialize(androidVerticalWheelWrapper.java:65)
... 26 more
** Activity (main) Resume **
** Activity (main) Resume **
Connected to B4A-Bridge (Wifi)
** Activity (main) Pause, UserClosed = false **
 

Johan Schoeman

Expert
Licensed User
Longtime User
B4A version 5.80
The 11th line from the bottom tells you what the problem is. You are missing files in the Objects/res/.....folders of the B4A project. Make sure they are there - look in the folders of the projects that I have posted and then make sure the files in those folders are set to READ ONLY.
 

suha

Member
Licensed User
Longtime User
Yes, this solved the problem! The files were not READ ONLY. I have just uncompressed your project using WinRAR as many other projects. I have not touched the file permissions. Can you tell what happened?


Thanks for the immediate help.
 

suha

Member
Licensed User
Longtime User
If the files are not read only, they disappear after the first compilation. That is a nicety.
 

adgency

New Member
Licensed User
Longtime User
Hi Johan,
great libary! Is it possible to have image spinner, but horizontal?
Thank you
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan,
great libary! Is it possible to have image spinner, but horizontal?
Thank you
Will see if I can add it to the horizontal wheel too.
 

susu

Well-Known Member
Licensed User
Longtime User
How can I add it by using code?
 

Johan Schoeman

Expert
Licensed User
Longtime User
How can I add it by using code?
In sub Globals:
B4X:
Private vsw1 As WheelVerticalView

In Activity_Create
B4X:
vsw1.Initialize("vsw1")
Activity.AddView(vsw1, 10%x, 10%y, 60%x, 50%y)

Remove the customview from the designer as it will now be added via code
 

Anser

Well-Known Member
Licensed User
Longtime User
Hi Johan,

The lib looks really nice. Good work

I am testing this lib using the sample app from post no #12 of this thread b4aAndroidSpinnerWheel.zip
I have used the Lib posted in the Post no #17 of this thread AndroidSpinnerWheel.zip.

Unfortunately when I compile the sample I app I get the following error

B4X:
B4A version: 5.80
Parsing code. (0.00s)
Compiling code. (0.02s)
Compiling layouts code. (0.00s)
Generating R file. (0.07s)
Compiling generated Java code. Error
Cannot find: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\nineoldandroids-2.4.0.jar
It looks like the lib is depended on nineoldandroids-2.4.0.jar


I already have NineOldAndroids by Informatix from the thread https://www.b4x.com/android/forum/threads/nineoldandroids.44393/

That's the only NineOldAndroids that I could find on this forum.

Any help will be appreciated

Regards
Anser
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan,

The lib looks really nice. Good work

I am testing this lib using the sample app from post no #12 of this thread b4aAndroidSpinnerWheel.zip
I have used the Lib posted in the Post no #17 of this thread AndroidSpinnerWheel.zip.

Unfortunately when I compile the sample I app I get the following error

B4X:
B4A version: 5.80
Parsing code. (0.00s)
Compiling code. (0.02s)
Compiling layouts code. (0.00s)
Generating R file. (0.07s)
Compiling generated Java code. Error
Cannot find: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\nineoldandroids-2.4.0.jar
It looks like the lib is depended on nineoldandroids-2.4.0.jar


I already have NineOldAndroids by Informatix from the thread https://www.b4x.com/android/forum/threads/nineoldandroids.44393/

That's the only NineOldAndroids that I could find on this forum.

Any help will be appreciated

Regards
Anser
@lemonisdead had a similar problem here....

https://www.b4x.com/android/forum/t...-100-embedded-in-b4a.63794/page-2#post-430029

Maybe she can shed some light on how she solved the problem. Have you tried to "clean" the project?
 

Anser

Well-Known Member
Licensed User
Longtime User
Sorry for creating the confusion.

As you have mentioned in the Thread Title that the latest lib is available in post #17, I straight away jumped into post #17 and downloaded it for my tests. Except the lib zip file in post #17,all the other previous library uploads by you in this thread contains the nineoldandroids-2.4.0.jar along with the Lib zip file .

Tested and it is working fine.

Regards
Anser
 

Anser

Well-Known Member
Licensed User
Longtime User
Your sample is working fine. But when I add to my existing project, I get the following compilation error. It looks like that is is related to the nineoldandroids.

B4X:
Parsing code.    (0.12s)
Compiling code.    (0.37s)
Compiling layouts code.    (0.03s)
Generating R file.    (0.90s)
Compiling generated Java code.    (2.53s)
Convert byte code - optimized dex.    Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/nineoldandroids/animation/Animator$AnimatorListener;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
    at com.android.dx.command.dexer.Main.processClass(Main.java:615)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
    at com.android.dx.command.dexer.Main.access$2(Main.java:546)
    at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:537)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
    at com.android.dx.command.dexer.Main.run(Main.java:206)
    at com.android.dx.command.dexer.Main.main(Main.java:179)
    at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting

Another thing noticed is that even though the nineoldandroids-2.4.0.jar is there in my additional lib folder it doesn't appear in the Libraries list.

In your sample, if you check the Libraries used, nineoldandroids-2.4.0.jar is not there in the list. It looks like your lib calls this internally.

Edit : - I assume that this lib is conflicting with some other libs already used in my project.
Edit : - If I remove this lib from my project then everything works fine. I tried clean project too.
 
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
Top