Attached project wraps this Github project. Posting:
1. B4A project
2. Library Files (2 x jar and 1 x xml) - copy them to your additional library folder.
You can also add the Wheel via code in stead of the Designer:
Some sample code:
The library:
AndroidWheel
Author: Github: Alessandro Crugnola, Wrapped by: Johan Schoeman
Version: 1
1. B4A project
2. Library Files (2 x jar and 1 x xml) - copy them to your additional library folder.
You can also add the Wheel via code in stead of the Designer:
B4X:
aw1.Initialize("aw1")
Activity.AddView(aw1, LEFT, TOP, WIDTH, HEIGHT)
Some sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: AndroidWheel
#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 aw1 As Wheel
Private aw2 As Wheel
Private l1 As Label
Private l2 As Label
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")
aw1.WheelScaleFactor = 2
aw1.TicksCount = 18
aw1.WheelMinValue = 0
aw1.WheelMaxValue = 100
'You must pass 3 colors if you want to change the gradient colors of the wheel's indicator
'The 3 default colors are 0xFF0076E7, 0xFF00BBFF, 0xFF0076E7
Dim indicatorcolors() As Int = Array As Int(Colors.Black, Colors.Black, Colors.Black)
aw1.IndicatorColors = indicatorcolors
'You must pass 5 colors if you want to change the gradient background colors of the wheel
'The 5 default colors are 0xffa1a1a1, 0xffa1a1a1, 0xffffffff, 0xffa1a1a1, 0xffa1a1a1
aw1.BackgroundColors = Array As Int(Colors.Yellow, Colors.Magenta, Colors.Cyan, Colors.Red, Colors.Green)
aw2.WheelScaleFactor = 2
aw2.TicksCount = 10
aw2.WheelMinValue = -50
aw2.WheelMaxValue = 50
'COMMENTED THE REST OF aw2 CODE TO USE DEFAULT COLORS AS DEFINED IN THE LIBRARY
'You must pass 3 colors if you want to change the gradient colors of the wheel's indicator
'The 3 default colors are 0xFF0076E7, 0xFF00BBFF, 0xFF0076E7
' Dim indicatorcolors() As Int = Array As Int(Colors.Black, Colors.Black, Colors.Black)
' aw2.IndicatorColors = indicatorcolors
'You must pass 5 colors if you want to change the gradient background colors of the wheel
'The 5 default colors are 0xffa1a1a1, 0xffa1a1a1, 0xffffffff, 0xffa1a1a1, 0xffa1a1a1
' aw2.BackgroundColors = Array As Int(Colors.Yellow, Colors.Magenta, Colors.Cyan, Colors.Red, Colors.Green)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub aw1_value_changed(retval As Float)
Log("aw1 value = " & retval)
l1.Text = retval
End Sub
Sub aw2_value_changed(retval As Float)
Log("aw2 value = " & retval)
l2.Text = retval
End Sub
The library:
AndroidWheel
Author: Github: Alessandro Crugnola, Wrapped by: Johan Schoeman
Version: 1
- Wheel
Events:- value_changed (retval as Float )
- ba As BA
- 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)
- Background As Drawable
- BackgroundColors() As Int [write only]
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- IndicatorColors() As Int [write only]
- Left As Int
- Tag As Object
- TicksCount As Int [write only]
Set the total number of ticks available for scrolling. - Top As Int
- Visible As Boolean
- WheelMaxValue As Float [write only]
Set the maximum value of the wheel
Default value = 100.0f - WheelMinValue As Float [write only]
Set the minimum value of the wheel
Default value = 0.0f - WheelScaleFactor As Int [write only]
Sets the wheel scale factor. - Width As Int