B4A Library [Class]ClsWheel Input wheels

SueHale

Member
Licensed User
Longtime User
Hi Klaus,

Thank-you for taking the time to explain one possible solution. I now think that on asking the question totally confused things.
I used your Wheel class to select the name of an audio file and this button code to load and play it.

B4X:
Sub Button1_Click
Dim MediaPlayer1 As MediaPlayer
MediaPlayer1.Initialize( )
    'Load MP3 files
    Select lblSelection.text
    Case "Harp"
        MediaPlayer1.Load(File.DirAssets, "harp.mp3")
    Case "Meep"
        MediaPlayer1.Load(File.DirAssets, "road.mp3")
    Case "Cartoon"
        MediaPlayer1.Load(File.DirAssets, "toon.mp3")
    Case "Chimes"
        MediaPlayer1.Load(File.DirAssets, "chimes.mp3")
    Case "Bongo"
        MediaPlayer1.Load(File.DirAssets, "temple.mp3")
    Case "Guitar"
        MediaPlayer1.Load(File.DirAssets, "suspense.mp3")
    Case "Tada"
        MediaPlayer1.Load(File.DirAssets, "tada.mp3")   
    Case "Saxaphone"
        MediaPlayer1.Load(File.DirAssets, "suspense.mp3")
    Case "Siren"
        MediaPlayer1.Load(File.DirAssets, "siren.mp3")   
    End Select
    MediaPlayer1.Play
       
End Sub

With regards
Sue.
 

klaus

Expert
Licensed User
Longtime User
If I understand now your question, did you want to get the position back ?
If this is the case I don't want to add it because it's only useful for one wheel.
If you have several wheels there would be different positions for each wheel.

In your case if the names in the wheel would have been the same as the generic names of the audio files you could have used:
MediaPlayer1.Load(File.DirAssets, lblSelection.Text & ".mp3")
But it's not the case.

Instead of using a Button to start the playing the file you could use an event for the wheel when the user clicks the OK button.

Best regards.
 
Last edited:

antonomase

Active Member
Licensed User
Longtime User
Hi,

When using clsWheel whith dateTime, I have an error "interval must be larger than 0" at line 752 (in debug mode)

The second time (in mode release), I have an error Unparseable date 11/22/2001 10:15" at java line 686
 

antonomase

Active Member
Licensed User
Longtime User
I try to change a label containing a chrono (lblTime.Text = "3:54")

My code
B4X:
Globals
    Dim lblTime as Label
    Dim whlTime As ClsWheel

Sub Activity_Create(FirstTime As Boolean)
    InitWheelChrono   
End Sub

Sub InitWheelChrono
    Dim lstChr(2) As List
    Dim i As Int
    lstChr(0).Initialize
    lstChr(1).Initialize
    For i=0 To 5
        lstChr(0).Add(i)
    Next
    For i= 0 To 9
        lstChr(1).Add("0" & i)
    Next
    For i= 10 To 59
        lstChr(1).Add(i)
    Next

    whlTime.Initialize(Me, Activity, "Time", 2, lstChr, 40, 4, True)
    whlTime.SetSeparationText(":")
End Sub

Sub lblTime_Longclick
    whlTime.Show2("whlTime", lblTime.Text)
End Sub

Sub whlTime_Closed(Canceled As Boolean, Selection As String)
    ' It works
End Sub

Each time I display the wheel, it is set to 5:59 instead to be displayed to the lblTime.Text value (e.g. 2:48)

Can you help me ?
Thanks
 

klaus

Expert
Licensed User
Longtime User
Change the InitWheelChrono like this:
B4X:
Sub InitWheelChrono
    Dim lstChr(2) As List
    Dim i As Int
    lstChr(0).Initialize
    lstChr(1).Initialize
  
    For i=0 To 5
        lstChr(0).Add(NumberFormat(i, 1, 0))
    Next

    For i = 0 To 59
        lstChr(1).Add(NumberFormat(i, 2, 0))
    Next

    whlTime.Initialize(Me, Activity, "Time", 2, lstChr, 40, 4, True)
    whlTime.SetSeparationText(":")
End Sub
The Custom wheel needs strings, but in your case you have Integers
 

moster67

Expert
Licensed User
Longtime User
Hi Klaus,

Thank you for this class. I am trying out the different solutions available here on the forum to use a wheel-view.

I have a problem with your class when I want to set the initial value (defaulvalue) of the wheel. I read earlier in this thread, this class was not meant for numbers but nevertheless, I will post my problem for you anyway

B4X:
Sub InitWheelData
   
    Dim mylist(1) As List
    mylist(0).Initialize
    mylist(0).Clear
   
'    if model="SS" then (50000 to 1000000) *divide with 1000 in list
    For x = 50 To 1000 Step 25
        mylist(0).Add(x)
    Next
   
    whlCustomSingle.Initialize(Me, Activity, "Select Bitrate", 1, mylist, 24, 4, True)
    whlCustomSingle.Show(lblTranscodingBitrateValue, "350")

    'whlCustomSingle.Show(lblTranscodingBitrateValue, lblTranscodingBitrateValue.Text)
   
End Sub

As you can see, in my case, "mylist" is not producing numbers strictly one after one (such as 1,2,3 etc) but I use an interval of 25.

How could I modify this part in the class

B4X:
If WheelNb = 1 Then
          ScrollPos(0) = lblHeight *(WheelContent(0).IndexOf(DefaulValue) + WheelContentNb(i))


to get "defaulvalue" positioned and working correctly in the wheel?

Thanks!
 

moster67

Expert
Licensed User
Longtime User
Works perfect. Much better to adjust code in origin instead of modifying the class-code.

Thank you Klaus.
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi Klaus!
First of all my compliments! Very good and useful work!

Only a question.
It's possible to customize the class in order to dispay a horizontal wheel?
 

klaus

Expert
Licensed User
Longtime User
Answer to the question of Johan Schoeman here.
Klaus, downloaded ClsWheel. When I start it and click on "Select date" the default date being displayed is 2013 September 21
Remove line 110 in the Main code :
whlDate.Initialize(Me, Activity, "Enter date", 3, Null, 24, 0, True)
 

Johan Schoeman

Expert
Licensed User
Longtime User
Don't know if it is the right/correct solution but if you call/add "show_today" from/to SUB Activity_Resume in WheelView (the only line of code that I have in this sub) then it seems to solve the problem. Have not had a failed start of day, month, year in any of the wheels despite numerous attempts.
 

klaus

Expert
Licensed User
Longtime User
Sorry, but I don't understand.
Are you speaking about ClsWheels or derezs' WheelView library.
The project you posted is not refered to the ClsWheels class so I can't help you.
I understoud that you were speaking about my ClsWheels class, when you posted this post, but your code has nothing to with it, and now I am confused ?
 

klaus

Expert
Licensed User
Longtime User
It's hardcoded in the Main module, which is only an example code, not in the Class.
You can change it in your application, you can show any date you want.
In the whlDate.Show method the first parameter is the view where the result will be shown and the second parameter is a String with the date to show when you call the wheel. In the example code it's a string variable with a given date format just as an example. If you set an empty string as the date parameter the wheel shows today.
Examples, where lblDate is the Label where the result is displayed:
B4X:
whlDate.Show(lblDate, dateEditText) ' date is a string variable
whlDate(lblDate, "21-09-2013") ' date is a fixed string
whlDate.Show(lblDate, lblDate.Text) ' date is the current date in the lblDate Label
whlDate(lblDate, "") ' date is today
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…