B4A Library Wheel by B4A Class

The new version 2 is amazing !
Here is the wheel library converted to b4a class at a very short time, and with better handling and options for the user/developer.

Documentation is within the class, a demo program is running the class - all very simple.

Applause to Erel :icon_clap:

Edit: updated to include a ReadWheel method, which I found necessary as well.
SetByIndex corrected to refer to the original array index.

Edit: Ver 2 can be used as custom view (starting b4a ver. 2.71) and also by code definition. If by designer - define the size of wheel, the properties of the text and then by code use "SetObject" to input the numbers of the wheel. The height of the internal labels is by default 1/3.2 of the view's height, or the "Text" field if you want it otherwise (or change by code using "SetStep").
If defined by code you have to use "initialize", then "CodeCreationView" and then add the view to its parent. In that case several display parameters are the defaults but can be changed by property subs.
To my opinion - it is much easier to define the wheel now by the designer :)(thanks Erel !). I wish it was possible to read the color of the lbl but it is writeable only...:(

Edit: I found a go around solution to define the color of the wheel as the color of the custom view in the designer, attached as ver. 2.1
Edit: Ver 2.2 enables definition of cyclic property in the designer. The text property may include 0,1 or 2 parameters, as defined in the following table:
table.png

Edit: Horizontal WheelView added, with the same properties. The table above refer to Width instead of Height.
Edit: Both vertical wheel and horizontal wheel were updated to use resumeable subs.

Note: The wheel is very sensitive to delay parameter (when setting it to show a value). You have to check the performance with Release mode.
 

Attachments

  • scsh.png
    scsh.png
    34.7 KB · Views: 1,950
  • Hscreen.png
    Hscreen.png
    21.6 KB · Views: 736
  • wheelview_3.zip
    18.3 KB · Views: 394
  • HWheelView_3.zip
    14.3 KB · Views: 338
Last edited:

derez

Expert
Licensed User
Longtime User
ReadWheel method added.

SetByIndex corrected to refer to the original array index.

The picture shows a date translation application I made with this Wheel.
 

Attachments

  • screenshot.png
    screenshot.png
    39.8 KB · Views: 999
Last edited:

birnesoft

Active Member
Licensed User
Longtime User
Don't compiles

I tried WheelViewC2 (1.1)

but b4a2.0 it tells


Compiling code. Error
Error parsing program.
Error description: Undeclared variable 'subexists' is used before it was assigned any value.
Occurred on line: 277
If SubExists(Wmodule, WEventName & "_Roll") Then

thanks Björn
 

birnesoft

Active Member
Licensed User
Longtime User
I love B4A

Thanks, that solved the Problem.
Everything is so easy!
I love B4A!!
Björn
 

BarrySumpter

Active Member
Licensed User
Longtime User
We had a question on how to calc for last day of month.
And I wanted to expand on the sample script by including a selected date instead of defaulting to Now.
So using the WheelView I slapped together somehthing kinda funny.

Run the app and select
2011 as the year then
02 as the month and
31 as the day.

In that order.
And just watch for a few seconds.

The label displayed with:
"a - selected date"
"b - last day of the month"
 

Attachments

  • WheelViewLastDayOfMonth.zip
    12.4 KB · Views: 308

Mahares

Expert
Licensed User
Longtime User
I took David Erez sample and BarrySumpter 's date validation sample, both deserve the full credit, then I added a couple of bells and whistles and came up with the attached sample Wheel Date. This shows you how the B4A members can work as a team.
 

Attachments

  • WheelDateMahares.zip
    12 KB · Views: 332
  • WheelDate.png
    WheelDate.png
    55 KB · Views: 632

BarrySumpter

Active Member
Licensed User
Longtime User
I was playing and thought the wheel change needed to be a bit faster by just snapping back to the corrected date.
Then I found your work.
Cool.
Nice to see someone elses enhancements.
Looks even better.
Thanks for the contribution.

--


Now a bit faster by just snapping back to the corrected date
I'm thinking the weels need to be on a panel to make it easier to center on screen. (not done)

B4X:
...
    If dd > 28 Then  'Check for Valid Date

        Do Until dd <= 28

            Try   ' with 2011 02 31
                DateTime.DateParse(mm & "/" & dd & "/" & yyyy)
                Exit   'Valid date - so exit
            Catch  'error  
                dd = dd - 1   ' 2011 02 30
            End Try
        
        Loop

        wc1.SetByIndex(dd)

    End If        
...
 

Attachments

  • WheelViewLastDayOfMonth2Snap.zip
    12 KB · Views: 269
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Yeah, ok.
Far too much fun. LOL.

wheel panel added - easier to centre

Very happy with the look n feel of this wheel.

Well done everyone!
 

Attachments

  • WheelViewLastDayOfMonth3SnapPanel.zip
    12 KB · Views: 308

AllanH

Member
Licensed User
Longtime User
iPhone version

Having looked at this class, I thought I could use it to mimic the iPhone 5 style spinner.
I have amended the class to allow extra padding (the current spinners just have one value above and below the selection, but I needed 2 on either side).
I have created two 9-patch graphics for the outer case and the inner bands. These graphics go behind the spinner, which needs to be transparent. I haven't removed the overlay in the code, however.
I then tidied up the date code so it is more locale-specific (although not going as far as changing the spinner's day-month-year order). I also changed the mechanism for detected an invalid date and moving back.
Hope you like it.
Just added code to remove scroll-marker and show an sample

Allan
 

Attachments

  • WheelClassMod.zip
    18.5 KB · Views: 415
  • Sample Screen of iPhone Spinner.png
    Sample Screen of iPhone Spinner.png
    55.9 KB · Views: 647
Last edited:

AllanH

Member
Licensed User
Longtime User
iPhone Spinner for dates, etc

Just added an example with even more padding (more useful for a lists of items that I have in mind than dates).

Also, I've split the 9-patches up so the thin middle bar can be made thinner/bigger depending on the font size you pick.

For the app in mind, I alread have a basic list that shows 7 items at any time in the bottom half of the screen.

Finally, I fixed a leak in the original code that did not remove old labels when you update any of the label properties (eg colour or style) - this is only visible on transparent labels that then overlap.

Allan
 

Attachments

  • WheelClassMod1.1.zip
    18.4 KB · Views: 478
  • Sample Screen of iPhone Spinner2.png
    Sample Screen of iPhone Spinner2.png
    62.2 KB · Views: 492

AllanH

Member
Licensed User
Longtime User
Note sure what graphic you are missing.
I have downloaded the zip to a separate directory, ran it in Basic4Android and it compiles and runs OK.

Allan
 

Harris

Expert
Licensed User
Longtime User
I downloaded and compiled zip from post 16 (1.1.zip). It worked.

Did notice that day one on the spinner showed day 3 ( 3 rather than 1). That was when trying to increase days past 31 (seemed sticky at this point). Going the other way (15 down to one) seemed to work properly.

Setting June 31 corrects to June 30 - nice....

Great work!
 
Top