B4A Library CharacterPickerView

It wraps this Github project. Take note of the following:
1. It was created with B4A V5.8 - so not sure if it will run on earlier B4A versions (although I think it should)
2. There are a number of files in the B4A project's /Object/res/..... folders. Once you have downloaded the project, make sure that the files in these folders are set to READ ONLY else they will be deleted when you compile the B4A project.
3. It raises an event in the B4A project when the values of a "Picker" has changed. See the code in the attached B4A project.

Spin them with your finger....

Posting:
1. B4A project to demonstrate the Pickers
2. B4A library files - copy them to your additional library folder

1.png


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: CharacterPickerView
    #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 cpv1 As CharacterPickerView
    Private cpv2 As CharacterPickerView
    Private cpv3 As CharacterPickerView
   
    Dim month(12) As String
    Dim day(31) As String
    Dim year(23) 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")
   
    Dim lst1 As List
    lst1.Initialize
    month = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    lst1.AddAll(month)
    cpv1.Picker = lst1
    cpv1.Cyclic = True
    cpv1.HorizontalLineColor = Colors.Magenta
    cpv1.OutsideTextColor = Colors.Blue
    cpv1.CentreTextColor = Colors.Red
    cpv1.Index = 4
   
    Dim lst2 As List
    lst2.Initialize
    day = Array As String("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31")
    lst2.AddAll(day)
    cpv2.Picker = lst2
    cpv2.Cyclic = True
    cpv2.HorizontalLineColor = Colors.Black
    cpv2.OutsideTextColor = Colors.Red
    cpv2.CentreTextColor = Colors.Blue
    cpv2.Index = 4
   
    Dim lst3 As List
    lst3.Initialize
    year = Array As String("1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021")
    lst3.AddAll(year)
    cpv3.Picker = lst3
    cpv3.Cyclic = True
    cpv3.HorizontalLineColor = Colors.Green
    cpv3.OutsideTextColor = Colors.Black
    cpv3.CentreTextColor = Colors.Cyan
    cpv3.Index = 17

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub cpv1_value_changed(cpv1Value As Int)
   
    Log("cpv1Value = " & cpv1Value)
    Log("cpv1Get = " & cpv1.SelectedIndex)
    Log("Month = " & month(cpv1Value))
   
End Sub

Sub cpv2_value_changed(cpv2Value As Int)
   
    Log("cpv2Value = " & cpv2Value)
    Log("cpv2Get = " & cpv2.SelectedIndex)
    Log("Day = " & day(cpv2Value))   
   
End Sub

Sub cpv3_value_changed(cpv3Value As Int)
   
    Log("cpv3Value = " & cpv3Value)
    Log("cpv3Get = " & cpv3.SelectedIndex)
    Log("Year = " & year(cpv3Value))   
   
End Sub

Library:

CharacterPickerView
Author:
Github: alafighting, Wrapped by: Johan Schoeman
Version: 1
  • CharacterPickerView
    Events:
    • value_changed (value 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)
    Properties:
    • Background As Drawable
    • CentreTextColor As Int [write only]
    • Color As Int [write only]
    • Cyclic As Boolean [write only]
    • Enabled As Boolean
    • Height As Int
    • HorizontalLineColor As Int [write only]
    • Index As Int [write only]
    • Left As Int
    • OutsideTextColor As Int [write only]
    • Parent As Object [read only]
    • Picker As List [write only]
    • SelectOptions As Int [write only]
    • SelectedIndex As Int [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • b4aCharacterPickerView.zip
    19.1 KB · Views: 373
  • CharacterPickerViewLibFiles.zip
    22.1 KB · Views: 361

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Thank you very much for your continuous contributions which is making B4A better and better .

2. There are a number of files in the B4A project's /Object/res/..... folders. Once you have downloaded the project, make sure that the files in these folders are set to READ ONLY else they will be deleted when you compile the B4A project.

Wouldn't using #AdditionalRes make it easier here ?
 
Top