I wrote this class to try to simplify porting a B4A app to B4i. The app uses Spinners, and I was frustrated by the lack of a suitable replacement. I tried Pickers, but they take up too much space. Also, a lot of fiddly changes/conditional compilation is required to handle differences between B4A and B4i, in particular differences in trivial things like the way you set the text size.
So, I wrote this class to mimic the B4A Spinner programming interface and hide a lot of the differences between B4a and B4i, thus reducing the number of changes/conditional compilation required. It's a CustomView, so can be set up in the Designer or created programmatically. The attached sample project contains examples of both.
Internally it's implemented as a Label which when clicked displays an action sheet for the user to make their selection.
The class expects the same _ItemClick callback as the B4A Spinner, and implements all of the B4A Spinner methods EXCEPT for the following:
Hugh
2015-12-08 Updated with V0.10
2016-04-20 Updated with V0.11
2016-07-06 Updated with V0.20
So, I wrote this class to mimic the B4A Spinner programming interface and hide a lot of the differences between B4a and B4i, thus reducing the number of changes/conditional compilation required. It's a CustomView, so can be set up in the Designer or created programmatically. The attached sample project contains examples of both.
Internally it's implemented as a Label which when clicked displays an action sheet for the user to make their selection.
The class expects the same _ItemClick callback as the B4A Spinner, and implements all of the B4A Spinner methods EXCEPT for the following:
- Background
- DropdownBackgroundColor
- DropdownTextColor
- Invalidate
- Invalidate2
- Invalidate3
- Prompt
- SetBackgroundImage
- SetColorAnimated
- SetVisibleAnimated
- SetCallbackModule - By default the class assumes that the callback routine is in the Main module. If it isn't you must call SetCallbackModule to set the module it is in. eg spr.SetCallbackModule(Me)
- View - returns the underlying Label used in the Spinner class. Useful for changing it's attributes directly
- GetBase - if the Spinner was created in the Designer then this returns the Base Panel containing the Spinner. If the Spinner was created programmatically then this return the underlying Label used in the Spinner class. Useful for adding the Spinner to a parent view. eg:
B4X:
myPanel.Addview (spr.GetBase, 0, 0, 20, 10)
- SetBorder - Set the border of the underlying label
- TextAlignment - attribute to get/set the alignment of the text in the underlying label.
Hugh
2015-12-08 Updated with V0.10
2016-04-20 Updated with V0.11
2016-07-06 Updated with V0.20
Attachments
Last edited: