It wraps this Github project. Posting the B4A project, the B4A library files, and the Java Code. There are a number of folders and files in the B4A project's /Objects/res folder. You will need them to be in any project that you create with this B4A project (not - all, but I leave it up to you to make sense of the files in the values and drawable folders and how to modify/use/adjust them).
For each view there are two events that will be raised:
1. selected - It is raised when you click on OK. In this event you can get a Boolean array of items selected in the list
2. cancelled - It is raised when you click on Cancel. In this event you can also get a Boolean array of items that are selected in the list. Just do the same call to for eg ms1.Selected as in the example code below/attached.
Some sample code:
MultiSpinner
Author: Johan Schoeman
Version: 1
For each view there are two events that will be raised:
1. selected - It is raised when you click on OK. In this event you can get a Boolean array of items selected in the list
2. cancelled - It is raised when you click on Cancel. In this event you can also get a Boolean array of items that are selected in the list. Just do the same call to for eg ms1.Selected as in the example code below/attached.
Some sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: MultiSpinner
#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 ms1, ms2 As MultiSpinner
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")
ms1.SpinnerData = Array As String("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
ms1.ShowTheSpinner
ms1.Selected = Array As Boolean(True, False, True, False, True, False, True)
ms2.SpinnerData = Array As String("Mercedes Benz", "BMW", "Nissan", "Toyota", "Hyundai", "Mitsubishi")
' if commented out then by default all will be unselected
' ms2.Selected = Array As Boolean(True, False, True, False, True, False)
ms2.ShowToastMessage = False
ms2.ShowTheSpinner
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ms1_selected
Dim selectitems() As Boolean
selectitems = ms1.Selected
For i = 0 To selectitems.Length - 1
Log("ms1 item " & i & " = " & selectitems(i))
Next
Log (" ")
End Sub
Sub ms2_selected
Dim selectitems() As Boolean
selectitems = ms2.Selected
For i = 0 To selectitems.Length - 1
Log("ms2 item " & i & " = " & selectitems(i))
Next
Log(" ")
End Sub
Sub ms1_cancelled
Log("ms1 Cancel clicked")
Log(" ")
End Sub
Sub ms2_cancelled
Log("ms2 Cancel clicked")
Log(" ")
End Sub
MultiSpinner
Author: Johan Schoeman
Version: 1
- MultiSpinner
Fields:- 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)
- SetTextColorAnimated (arg0 As Int, arg1 As Int)
- SetTextSizeAnimated (arg0 As Int, arg1 As Float)
- SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
- ShowTheSpinner
- Background As Drawable
- Color As Int [write only]
- Enabled As Boolean
- Gravity As Int
- Height As Int
- Left As Int
- Selected()() As Boolean
- ShowToastMessage As Boolean [write only]
- SpinnerData() As String [write only]
- Tag As Object
- Text As String
- TextColor As Int
- TextSize As Float
- Top As Int
- Typeface As Typeface
- Visible As Boolean
- Width As Int