B4A Library [Class]ClsWheel Input wheels

Attached you find a new CLASS ClsWheel.

It allows to display different data input screens with wheels.

What can be done ?
You can define nine different types of Wheel input screens:
  • DATE a date input : year / month / day
    A default value can be defined or Now, the current date.
    The returned value has the current DateFormat.
  • TIME_HM a time input : hour / minute
    A default value can be defined or Now, the current time.
    The returned value has the current TimeFormat.
  • TIME_HMS a time input : hour / minute / second
    A default value can be defined or Now, the current time.
    The returned value has the current TimeFormat.
  • DATE_TIME a date + time input : year / month / day / hour / minute
    A default value can be defined or Now, the current date and time.
    The returned value has the current DateFormat and TimeFormat.
  • CUSTOM a custom input with user defined input values.
    The number of side by side wheels is user defined (max. 5 wheels).
    A default value can be defined.
    A specific separation character can be defined, a blanc character is default.
  • INTEGER positive and negative integers
  • INTEGER_POS only positive integers
  • NUMBER positive and negative numbers
  • NUMBER_POS only positive numbers
Main functions:
Initialize initializes the wheel class Note: the Initialize routine hasone more parameter cContinusScrolling As Boolean (since version 1.3) .
Example :
whlDate.Initialize(Me, Activity, "Enter date", 3, Null, 24, 0, True)
Me = calling module, the current
Activity =
Enter date = title of the input
3 = number of wheels, this number is used only for CUSTOM input types
Null = no input data, set internally
24 = text size
0 = DATE input type
True = continus scrolling

Show show the input wheel(s)
Example :
whlDate.Show(lblSelection, "11/22/2001")
lblSelection = Label which gets the result
11/22/2001 = Default value to preset the wheels

Show2 show the input wheel(s)
Example :
whlCustum.Show2("whlCustom", "")
"whlCustom" = EventName
"" = no default value
The event is called 'Closed'.
The event routine in the calling module, for the example, must be
Sub whlCustom_Closed(Canceled As Boolean, Selection As String)

The width and height are defined by the program according to the font size.

If the width or the height exceed the screen width or height the font size is downscaled.

You can change most of the colors.

Needs the Reflection library.

Bug reports and suggestions are welcome.

I hope that the code is enough self explanatory, but if you want more explanations I can add them.
Anyway the best way to know what can be done is to test it.

PS. There is no logic in the custom input screen just to demonstrate the possibility.

Best regards.


EDIT: 2020.11.25 Version 2.7
Amended warning in line 946: Comparison of Object to other types will fail if exact types do not match.
EDIT: 2015.04.29 Version 2.0
Added a Tag property

EDIT: 2017.06.27 Version 2.6
Replaced DoEvents by Sleep(0)
Needs B4A version 7.00+

EDIT: 2017.03.30 Version 2.5
Amended the wish expressed HERE
Different font sizes for title and wheels.
With long titles, the font size of both, title and wheels, was reduced.
Now only the title font size is reduced.

EDIT: 2017.03.28 Version 2.4
Amended the error reported HERE
Problem with +/- in number wheels

EDIT: 2015.09.22 Version 2.3
Amended the error reported in post #185

EDIT: 2015.05.10 Version 2.2
Amended the variable declaration problem reported in post #175

EDIT: 2015.05.10 Version 2.1
Amended the timer problem reported in post #170

EDIT: 2014.09.09 Version 1.9
Added number wheels INTEGER, INTEGER_POS, NUMBER, NUMBER_POS wheels
Amended day scroll problem reported in post #141

EDIT: 2014.04.21 Version 1.7
Amended OutOfMemory problem reported HERE.

EDIT: 2013.09.15 Version 1.6
Added min MinYear and NumberOfYears properties to adapt the years to select

EDIT: 2013.08.08 Version 1.5
Added StartScroll and EdnScroll events

EDIT: 2013.06.14 Version 1.4
Modified OK event to Closed event post#37
Amended screen color problem post#36
Amendet getSeparationText error post #41

EDIT: 2013.06.12 Version 1.3
Mofied property routines.
Added Show2 for raising an event when clicking the OK button
Added optional continus scrolling

EDIT: 2013.05.28 Version 1.2
Amended the bug reported in post #32

EDIT: 2012.12.15 Version 1.1
Amended the reported bugs.
 

Attachments

  • Time_input.jpg
    Time_input.jpg
    32.9 KB · Views: 2,270
  • Custom_input.jpg
    Custom_input.jpg
    45.3 KB · Views: 2,186
  • ClsWheelV2_5.zip
    19.1 KB · Views: 473
  • ClsWheelV2_7.zip
    19.3 KB · Views: 487
Last edited:

Espinosa4

Active Member
Licensed User
Longtime User
Hi Klaus,

Yes, I am.
In all android versions works fine but in Android 5.x.x the "problem" appears".

And yes, when a push the buttons the click event is fired again.

I don't know how to fix it. It is not a big problem. People can work perfectly but it is strange.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
I saw it too on my Sony xperia Z1 withAndroid 5.0.2.
After adding this line SetApplicationAttribute(android:theme, "@android:style/Theme.Holo") to the Manifest Editor it works as expected again.

With this Manifest Editor content it works OK.
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.
 

Espinosa4

Active Member
Licensed User
Longtime User
Thanks Klaus,

I'll edit the manifest and test the program and I'll comment but sure your reply is the answer to my problem..

Cheers
 

Espinosa4

Active Member
Licensed User
Longtime User
Hi Klaus,

Thank you for your help.
Following your advices all is OK now.

My API Level was 10. Now I am working with API 15 and all is OK.

Best regards,
Espinosa
 

AHilberink

Active Member
Licensed User
Longtime User
Hi Klaus,

3 weeks ago I downloaded your libary. Thank you for your sharing and nice work.

But I found a problem using the DATE scroll. For example: today it's 22. I changed it to 18. Then I changed the month. The day is changed of value, in my case 09.

I found the problem after testing in line 997:
B4X:
CurrentDayIndex = Floor(scvWheel(1).ScrollPosition / lblHeight + 0.5) - WheelContentNb(1)

Should be:
B4X:
CurrentDayIndex = Floor(scvWheel(2).ScrollPosition / lblHeight + 0.5) - WheelContentNb(2)

May be I am wrong, may be you already know, but for me it works fine now.

Best regards,
André
 

CaStar

Member
Licensed User
Longtime User
Show2 Example


Hello Klaus,
in your 1st post there is an error in your Show2 example. I spent a little time to figure this out because I did a simple "copy" of the statement and the closed procedure didn't start after closing the wheel.

The correct statement should be:

whlCustom.Show2("whlCustom", "")

 

AHilberink

Active Member
Licensed User
Longtime User
I wonder if someone experience this:
During showing the wheels, a user did use the external keyboard with for example a 1.

Error:
java.text.ParseException: Unparseable date: "1" (at offset 1)

Can I protect the user of using the keyboard? Is it possible to avoid this error?

Best regards,
André
 

cimperia

Active Member
Licensed User
Longtime User
You could wrap the code in a Try...Catch block?
 

Cebuvi

Active Member
Licensed User
Longtime User
Hi,

Using the class with B4A v7.01, this error occurs when replacing DoEvents for Sleep(0) in the Initialize Sub

Error compiling program.
Error description: Initialize sub cannot be resumable.

Can I make the change to Sleep (0) without having this error?.

Thanks

César
 

Star-Dust

Expert
Licensed User
Longtime User
Or no, do not ... I want my Doevents o_Oo_Oo_O
 
Top