B4A Library Another WheelView

It is a (partly) wrap for this Github project. Posting the following:
1. B4A library files
2. B4A sample project

Note that the selected item is clickable.

1.gif


Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: WheelViewNew
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #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 wvn1 As WheelViewNew
    Private wvn2 As WheelViewNew
    Private wvn3 As WheelViewNew
   
    Private wvn4 As WheelViewNew
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 mycountdata As List
    mycountdata.Initialize2(Array As String("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight"))
    wvn1.addData(mycountdata)
   
    wvn1.Skin = wvn1.SKIN_TYPE_COMMON
    wvn1.WheelClickable = True
    wvn1.WheelLoop = True
    wvn1.Selection = 3                        'index starts at 0
    wvn1.WheelSize = 5

    'this will set the style - keep the order of the code i.e wvn1.applyStyle should be called last
    wvn1.WheelBackgroundColor = Colors.Gray
    wvn1.NonSelectedTextSize = 15
    wvn1.NonSelectedTextColor = Colors.White
    wvn1.SelectedTextSize = 17
    wvn1.SelectedTextColor = Colors.Black
    wvn1.applyStyle
   
   
   
    Dim mydaydata As List
    mydaydata.Initialize2(Array As String("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
    wvn2.addData(mydaydata)
   
    wvn2.Skin = wvn2.SKIN_TYPE_HOLO
    wvn2.WheelClickable = True
    wvn2.WheelLoop = True
    wvn2.Selection = 0                        'index starts at 0
    wvn2.WheelSize = 3

    'this will set the style - keep the order of the code i.e wvn2.applyStyle should be called last
    wvn2.WheelBackgroundColor = Colors.White
    wvn2.NonSelectedTextSize = 15
    wvn2.NonSelectedTextColor = Colors.Black
    wvn2.SelectedTextSize = 17
    wvn2.SelectedTextColor = Colors.Red
    wvn2.applyStyle   
   
   
    Dim mymonthdata As List
    mymonthdata.Initialize2(Array As String("January", "February", "March", "April", "May", "June", "July", _
                                            "August", "September", "October", "November", "December"))
    wvn3.addData(mymonthdata)
   
    wvn3.Skin = wvn3.SKIN_TYPE_HOLO
    wvn3.WheelClickable = True
    wvn3.WheelLoop = True
    wvn3.Selection = 4                        'index starts at 0
    wvn3.WheelSize = 3

    'this will set the style - keep the order of the code i.e wvn3.applyStyle should be called last
    wvn3.WheelBackgroundColor = Colors.Cyan
    wvn3.NonSelectedTextSize = 15
    wvn3.NonSelectedTextColor = Colors.Blue
    wvn3.SelectedTextSize = 17
    wvn3.SelectedTextColor = Colors.Magenta
    wvn3.applyStyle       
   
   
    Dim mn As String
    Dim mynumberdata As List
    mynumberdata.Initialize
    For i = 0 To 9
        mn = ""
        If i < 10 Then mn = "0" & i
        mynumberdata.Add(mn)
    Next
  

    wvn4.addData(mynumberdata)
   
    wvn4.Skin = wvn4.SKIN_TYPE_COMMON
    wvn4.WheelClickable = True
    wvn4.WheelLoop = True
    wvn4.Selection = 5                        'index starts at 0
    wvn4.WheelSize = 3

    'this will set the style - keep the order of the code i.e wvn4.applyStyle should be called last
    wvn4.WheelBackgroundColor = Colors.Cyan
    wvn4.NonSelectedTextSize = 15
    wvn4.NonSelectedTextColor = Colors.Blue
    wvn4.SelectedTextSize = 17
    wvn4.SelectedTextColor = Colors.Magenta
    wvn4.applyStyle           
   

End Sub

Sub Activity_Resume
   

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub wvn1_wheel_clicked(position As Int)
   
    Log("wvn1 Position = " & position)
   
End Sub

Sub wvn1_item_selected(selection As Int)
   
    Log("wvn1 Item Selected = " & selection)
   
End Sub

Sub wvn2_wheel_clicked(position As Int)
   
    Log("wvn2 Position = " & position)
   
End Sub

Sub wvn2_item_selected(selection As Int)
   
    Log("wvn2 Item Selected = " & selection)
   
End Sub

Sub wvn3_wheel_clicked(position As Int)
   
    Log("wvn3 Position = " & position)
   
End Sub

Sub wvn3_item_selected(selection As Int)
   
    Log("wvn3 Item Selected = " & selection)
   
End Sub

Sub wvn4_wheel_clicked(position As Int)
   
    Log("wvn4 Position = " & position)
   
End Sub

Sub wvn4_item_selected(selection As Int)
   
    Log("wvn4 Item Selected = " & selection)
   
End Sub

Library:
WheelViewNew
Author: Github: venshine (https://github.com/venshine/WheelView), Wrapped by: Johan Schoeman
Version: 1.03
  • WheelViewNew
    Events:
    • item_selected (position As Int)
    • wheel_clicked (position As Int)
    Fields:
    • SKIN_TYPE_COMMON As Int
    • SKIN_TYPE_HOLO As Int
    • SKIN_TYPE_NONE As Int
    • 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)
    • addData (data As List)
    • applyStyle
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • NonSelectedTextColor As Int [write only]
    • NonSelectedTextSize As Int [write only]
    • Parent As Object [read only]
    • SelectedTextColor As Int [write only]
    • SelectedTextSize As Int [write only]
    • Selection As Int [write only]
    • Skin As Int [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • WheelBackgroundColor As Int [write only]
    • WheelClickable As Boolean [write only]
    • WheelLoop As Boolean [write only]
    • WheelSize As Int [write only]
      This must be an UNEVEN number and must be greater than the number of entries in the list
      of data that is passed with "addData"
    • Width As Int
 

Attachments

  • WheelViewNewLibFiles.zip
    33 KB · Views: 245
  • b4aWheelViewNew.zip
    8.5 KB · Views: 232

jose luis gudino

Active Member
Licensed User
Hi, I have the following issue.
It does not work correctly.
How can you see in the image the lines of division do not appear
Events are not running either.

img.jpg
 

Johan Schoeman

Expert
Licensed User
Hi, I have the following issue.
It does not work correctly.
How can you see in the image the lines of division do not appear
Events are not running either.

img.jpg
Can you upload your sample project or send me a link to it?
 

jose luis gudino

Active Member
Licensed User
Hello, thanks for your time
I tried in a clean application and it worked correctly, I do not really know what the problem is, I'm going to make some changes, if it does not work I'll upload part of the project
regards
 

chaya

Member
Licensed User
is it possible to select item at activity_create?
let's say I have a wheel of number 1 to 12, and want the number 5 to be selected, before the user scrolls.
 

DonManfred

Expert
Licensed User
let's say I have a wheel of number 1 to 12, and want the number 5 to be selected, before the user scrolls.

Properties:
  • Background As Drawable
  • Color As Int [write only]
  • Enabled As Boolean
  • Height As Int
  • Left As Int
  • NonSelectedTextColor As Int [write only]
  • NonSelectedTextSize As Int [write only]
  • Parent As Object [read only]
  • SelectedTextColor As Int [write only]
  • SelectedTextSize As Int [write only]
  • Selection As Int [write only] ' <<<<<<<<<<<<<<<<<<<<
B4X:
wvn1.Selection = 4
?
 

Myr0n

Active Member
Licensed User
is it possible to select item at activity_create?
let's say I have a wheel of number 1 to 12, and want the number 5 to be selected, before the user scrolls.

Use :
wvn1.Selection = 3 'index starts at 0
 
Top