B4A Library WheelPicker

A wrap for this Github project. Posting the following:
1. B4A sample project
2. B4A library files - copy them to your additional library folder
3. The Java code - change it whichever way you want

Edit: Version 1.11 in post #31 of this thread

1.gif


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

#AdditionalRes: ..\wheelpicker_resource

#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 wp1 As WheelPicker
    Private wp2 As WheelPicker
  
    Dim mydaylist As List
    Dim mymonthlist As List   
  
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")
  
    wp1.Curved = True
    wp1.Cyclic = True
    wp1.CurtainColor = Colors.ARGB(50, 255, 255, 255)   
    wp1.Curtain = True
    wp1.ItemTextColor = Colors.White
    wp1.Atmospheric = True
    wp1.ItemAlign = 0                        '0 = center, 1 = left, 2 = right
    wp1.ItemTextSize = 40   
    wp1.SelectedItemPosition = 3             'it will start at Thursday  
    wp1.SelectedItemTextColor = Colors.Magenta
    wp1.VisibleItemCount = 4
    wp1.SameWidth = True                     'not sure what this is supposed to do
  
  
    mydaylist.Initialize
    mydaylist.AddAll(Array As String("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
    wp1.Data = mydaylist
  
  
    wp2.Curved = True
    wp2.Cyclic = True
    wp2.CurtainColor = Colors.ARGB(100, 255, 0, 0)   
    wp2.Curtain = True
    wp2.ItemTextColor = Colors.Yellow
    wp2.Atmospheric = True
    wp2.ItemAlign = 0                        '0 = center, 1 = left, 2 = right
    wp2.ItemTextSize = 40   
    wp2.SelectedItemPosition = 7             'it will start at August 
    wp2.SelectedItemTextColor = Colors.Cyan
    wp2.VisibleItemCount = 6
    wp2.SameWidth = True                     'not sure what this is supposed to do
  
  
    mymonthlist.Initialize
    mymonthlist.AddAll(Array As String("January", "February", "March", "April", "May", "June", "July", _
                                     "August", "September", "October", "November", "December"))
    wp2.Data = mymonthlist  
  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub wp1_item_selected(position As Int)
  
    Log("wp1 position = " & position & "  value = " & mydaylist.Get(position))
  
End Sub


Sub wp2_item_selected(position As Int)
  
    Log("wp2 position = " & position & "  value = " & mymonthlist.Get(position))
  
End Sub

Library as it is at present:

WheelPicker
Author:
Github: AigeStudio, Wrapped by: Johan Schoeman
Version: 1
  • WheelPicker
    Events:
    • item_selected (position 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)
    • onItemSelected (picker As WheelPicker, data As Object, position As Int)
    Properties:
    • Atmospheric As Boolean [write only]
    • Background As Drawable
    • Color As Int [write only]
    • Curtain As Boolean [write only]
    • CurtainColor As Int [write only]
    • Curved As Boolean [write only]
    • Cyclic As Boolean [write only]
    • Data As List [write only]
    • Enabled As Boolean
    • Height As Int
    • Indicator As Boolean [write only]
    • ItemAlign As Int [write only]
    • ItemTextColor As Int [write only]
    • ItemTextSize As Int [write only]
    • Left As Int
    • Parent As Object [read only]
    • SameWidth As Boolean [write only]
    • SelectedItemPosition As Int [write only]
    • SelectedItemTextColor As Int [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • VisibleItemCount As Int [write only]
    • Width As Int
 

Attachments

  • TheJavaCode.zip
    15.7 KB · Views: 688
  • b4aWheelPicker.zip
    407.3 KB · Views: 900
  • WheelPickerLibFiles.zip
    17 KB · Views: 813
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
The code is as follows:
Dim wpYear As WheelPicker
wpYear.Initialize("wpYear")
The following error occurred during initialization:
android.content.res.Resources$NotFoundException: String array resource ID #0x0
See post #31 above.
 
Top