B4A Library [B4X] [XUI] AS WheelPicker - Spinner - a modern single/multiple choice picker view - based on xCustomListView [Payware]

jboavida

Member
Licensed User
Longtime User
Hello,
I have a compiler problem. I use android Phone V10. And B4A 11.0. I'm using the example provided
Please help. Thanks


Joaquim
 

jboavida

Member
Licensed User
Longtime User
Hi, Can you share a more complete example please? I want to to integrate the picker on my app. From the example source code is not easy...
Sorry i'm not very experienced. My application does not use b4xmainpage and compiles well. I just want to to add a number picker.
Thanks
 

jboavida

Member
Licensed User
Longtime User
Hi,
It is working. But I have now another problem. I want to add 4 different pickers with 4 numbers each. I have created the pickers also in the designer (exact copy) and every one of them work fine except for the font size and separator... font is ok on picker 1 and 3 and separator is ok on picker 2 and 4..
What i'm doing wrong?

Thanks and sorry for all the questions.


B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ASWheelPicker1 As ASWheelPicker
    Private ASWheelPicker2 As ASWheelPicker   
    Private ASWheelPicker3 As ASWheelPicker
    Private ASWheelPicker4 As ASWheelPicker

End Sub

Public Sub Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("frm_main")
    B4XPages.SetTitle(Me,"Pa_Price")
    
    'ASWheelPicker1.CornerRadius = 20dip'can be set in the designer
    
    
    
    
    ASWheelPicker1.RowHeightSelected = 70dip
    ASWheelPicker1.RowHeightUnSelected = 60dip
    
    ASWheelPicker2.RowHeightSelected = 70dip
    ASWheelPicker2.RowHeightUnSelected = 60dip
    
    ASWheelPicker3.RowHeightSelected = 70dip
    ASWheelPicker3.RowHeightUnSelected = 60dip
    
    ASWheelPicker4.RowHeightSelected = 70dip
    ASWheelPicker4.RowHeightUnSelected = 60dip
    

    ASWheelPicker1.ItemTextProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the items bold
    ASWheelPicker2.SeperatorProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the seperator text bold
    ASWheelPicker3.ItemTextProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the items bold
    ASWheelPicker4.SeperatorProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the seperator text bold
    
    ASWheelPicker1.FadeColor = xui.Color_Transparent 'no fade color effect
    'set the same color as the view so that the upper and lower numbers are not visible and there is a slide in effect
    ASWheelPicker1.TopFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)
    ASWheelPicker1.BottomFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)

    ASWheelPicker2.FadeColor = xui.Color_Transparent 'no fade color effect
    'set the same color as the view so that the upper and lower numbers are not visible and there is a slide in effect
    ASWheelPicker2.TopFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)
    ASWheelPicker2.BottomFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)

    ASWheelPicker3.FadeColor = xui.Color_Transparent 'no fade color effect
    'set the same color as the view so that the upper and lower numbers are not visible and there is a slide in effect
    ASWheelPicker3.TopFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)
    ASWheelPicker3.BottomFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)

    ASWheelPicker4.FadeColor = xui.Color_Transparent 'no fade color effect
    'set the same color as the view so that the upper and lower numbers are not visible and there is a slide in effect
    ASWheelPicker4.TopFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)
    ASWheelPicker4.BottomFadePanel.Color = xui.Color_ARGB(255,60, 64, 67)



    
    'Add the numbers to wheel 1
    Dim tmp_lst As List : tmp_lst.Initialize
    For i = 0 To 9
        tmp_lst.Add(i)
    Next
    ASWheelPicker1.AddWheel(tmp_lst)
    ASWheelPicker1.AddWheel(tmp_lst)
    ASWheelPicker1.AddWheel(tmp_lst)
    ASWheelPicker1.AddWheel(tmp_lst)
    ASWheelPicker1.SeperatorProperties.BackgroundColor = xui.Color_ARGB(255,60, 64, 67)'sets the seperator backgroundcolor matched to the view background color
    ASWheelPicker1.AddSeperator(0,15dip,".")'adds the seperator
    
    ASWheelPicker2.AddWheel(tmp_lst)
    ASWheelPicker2.AddWheel(tmp_lst)
    ASWheelPicker2.AddWheel(tmp_lst)
    ASWheelPicker2.AddWheel(tmp_lst)
    ASWheelPicker2.SeperatorProperties.BackgroundColor = xui.Color_ARGB(255,60, 64, 67)'sets the seperator backgroundcolor matched to the view background color
    ASWheelPicker2.AddSeperator(0,15dip,".")'adds the seperator

    ASWheelPicker3.AddWheel(tmp_lst)
    ASWheelPicker3.AddWheel(tmp_lst)
    ASWheelPicker3.AddWheel(tmp_lst)
    ASWheelPicker3.AddWheel(tmp_lst)
    ASWheelPicker3.SeperatorProperties.BackgroundColor = xui.Color_ARGB(255,60, 64, 67)'sets the seperator backgroundcolor matched to the view background color
    ASWheelPicker3.AddSeperator(0,15dip,".")'adds the seperator

    ASWheelPicker4.AddWheel(tmp_lst)
    ASWheelPicker4.AddWheel(tmp_lst)
    ASWheelPicker4.AddWheel(tmp_lst)
    ASWheelPicker4.AddWheel(tmp_lst)
    ASWheelPicker4.SeperatorProperties.BackgroundColor = xui.Color_ARGB(255,60, 64, 67)'sets the seperator backgroundcolor matched to the view background color
    ASWheelPicker4.AddSeperator(0,15dip,".")'adds the seperator
    
End Sub


Private Sub B4XSwitch1_ValueChanged (Value As Boolean)
    If Value Then
        ASWheelPicker1.SelectionBarColor = xui.Color_Transparent
        ASWheelPicker2.SelectionBarColor = xui.Color_Transparent
        ASWheelPicker3.SelectionBarColor = xui.Color_Transparent
        ASWheelPicker4.SelectionBarColor = xui.Color_Transparent
    Else
        ASWheelPicker1.SelectionBarColor = xui.Color_White
        ASWheelPicker2.SelectionBarColor = xui.Color_White
        ASWheelPicker3.SelectionBarColor = xui.Color_White
        ASWheelPicker4.SelectionBarColor = xui.Color_White
    End If
End Sub

Private Sub ASWheelPicker1_ItemSnapped(wheel_index As Int,list_index As Int)
    Log("Index: " & list_index)
End Sub

Private Sub ASWheelPicker2_ItemSnapped(wheel_index As Int,list_index As Int)
    Log("Index: " & list_index)
End Sub

Private Sub ASWheelPicker3_ItemSnapped(wheel_index As Int,list_index As Int)
    Log("Index: " & list_index)
End Sub

Private Sub ASWheelPicker4_ItemSnapped(wheel_index As Int,list_index As Int)
    Log("Index: " & list_index)
End Sub
 

Alexander Stolte

Expert
Licensed User
Longtime User
What i'm doing wrong?
B4X:
    ASWheelPicker1.ItemTextProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the items bold
    ASWheelPicker2.SeperatorProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the seperator text bold
    ASWheelPicker3.ItemTextProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the items bold
    ASWheelPicker4.SeperatorProperties.TextFont = xui.CreateDefaultBoldFont(50) 'makes the seperator text bold
Because you are changing only for Picker 1 and 3 the ItemTextProperties for the other 2 you are only changing the SeperatorProperties.
 

jboavida

Member
Licensed User
Longtime User
Hi All,
It's me again....
Code is almost done and working ok. I'm in the final tests in several different devices.
It works ok in Android 10 devices, but in one device with android 8.1 it fails.



The program crashes at line 178


it only happens with the device using android 8.1

Thanks
 

Attachments

  • 1630319688346.png
    26.8 KB · Views: 179

Lello1964

Well-Known Member
Licensed User
Longtime User
I'm trying to use AsWheelPicker in B4J and i wanna use it with next and previous item with arrows. I put all dependencies but it doesn't work.
Could you help me please, can tell ma a sample with up and down ?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Could you help me please, can tell ma a sample with up and down ?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 2.03
    • Add Event BaseResize - Triggers as soon as the width in the view has changed
    • Add Event ItemChange - Triggers when an item reaches the center while scrolling, so you can display the results e.g. in a label instant
    • B4I Item snap is now smooth
ItemChange
with this event you can do something like this:

B4I Item snap is now smooth
In B4A it already feels smooth enough, but in B4I it feels much better now.
BaseResize
will only become relevant in the next update. In the next update you can adjust the width of the wheels themselves, so it is possible to display more text with more width if you need it.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
There is a backup of version 2.03 in the 1st post in case of problems

  • 2.04 (read more)
    • Complete rework of the wheel sizing
    • Add Designer Property WidthMode - Default: Automatic
      • Automatic - You don't have to worry about anything, the view calculates the right size for all wheels
      • Manual - Set the wheel sizes you need via "SetWheelWidth"
    • Add WheelWidth to ItemTextProperties - This allows you to set the width of a wheel manually, only working if WidthMode = Manual - Default: 0
    • Add SetWheelWidth - Sets the width of an wheel, only working if WidthMode = Manual
    • Add get and set Events - Enables or disables the events
    • Haptic feedback disabled if you call Scroll2Index
    • BugFixes
WidthMode = Manual
You can now determine and divide the width of the wheels yourself.
For example, the 1st wheel has a width of 70% of the total width of the view, the 2nd wheel has the remaining 30%.

B4X:
Private Sub B4XPage_Resize (Width As Int, Height As Int)
    If ASWheelPicker1.NumberOfLists = 2 Then 'To ensure that the code is not executed until the 2 wheels have been added
        ASWheelPicker1.SetWheelWidth(0,(Width*70)/100)'70% of total width
        ASWheelPicker1.SetWheelWidth(1,(Width*30)/100)'30% of total width
    End If
End Sub
Is compatible too with Separators

*Red = Separators
*Blue = Items
 

Lisa I

Member
Licensed User
I have your excellent ASwheelpicker library and wondered if you were aware of any issues with Android 12.
Unfortunately I don't have an Android 12 device yet, before I go out and purchase one for debugging I just wanted to check.

I have a customer whose app is crashing when he opens a page with wheelpickers on (it's working fine in Android 11), everything else in the app is working.

Thank you
Lisa

B4X:
TyreWheelPicker1.Curved = True
    TyreWheelPicker1.Cyclic = True
    TyreWheelPicker1.CurtainColor = Colors.ARGB(50, 100, 100, 100)
    TyreWheelPicker1.Curtain = True
    TyreWheelPicker1.ItemTextColor = Colors.Black
    TyreWheelPicker1.Atmospheric = True
    TyreWheelPicker1.ItemAlign = 0                     
    TyreWheelPicker1.ItemTextSize = 80
    TyreWheelPicker1.SelectedItemPosition = 0            
    TyreWheelPicker1.SelectedItemTextColor = Colors.Black
    TyreWheelPicker1.VisibleItemCount = 3
    TyreWheelPicker1.SameWidth = True
    tyrelist.Initialize
    tyrelist.AddAll(Array As String("ALL",0,1,2,3,4,5,6,7,8,9,10))
    TyreWheelPicker1.Data = tyrelist
 

Alexander Stolte

Expert
Licensed User
Longtime User
Thats not the ASWheelPicker, sorry.
 

astronald

Active Member
Licensed User
Longtime User
Hello, thanks for your work
I try implement ASwheel in B4I B4Xpages Dialog
in B4A work great but B4I fire this error

Error occurred on line: 368 (ASWheelPicker)
Object was not initialized (UIView)
-[b4i_customlistview _designercreateview:::] + 672
Thanks for your time and help
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…