Android Tutorial [B4X] B4XPlusMinus - Spinner / wheel alternative

Discussion in 'Tutorials & Examples' started by Erel, Apr 29, 2019.

  1. Erel

    Erel Administrator Staff Member Licensed User

    B4XPlusMinus is a cross platform control introduced in XUI Views v2.05: https://www.b4x.com/android/forum/threads/b4x-xui-views-cross-platform-views-and-dialogs.100836/

    [​IMG]

    As you can see in the above image it supports three different formations: horizontal, vertical and bottom. The bottom formation is useful with smaller controls to prevent the user finger from hiding the value.

    There are two ways to set the values:

    SetStringItems - A list or array with the items:
    Code:
    pm.SetStringItems(Array("aaa""bbb"))
    SetNumericRange - A numeric range:
    Code:
    pm.SetNumericRange(11002'1 - 100 with interval of 2.
    Numeric values are converted to strings with the help of B4XFormatter.
    The controls color and text size is set with the designer. Other options:
    [​IMG]

    Cyclic - Whether to move to the first item after the last item.
    Rapid - Whether to allow rapid changes with long clicks. Note that you can change the durations used for the rapid effect (RapidPeriod1 and RapidPeriod2 fields - default values are 1000ms and 30ms).

    Example is attached.
     

    Attached Files:

    paragkini, AnandGupta, jimmyF and 6 others like this.
  2. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    i have this error on the example:
    Code:
    java.lang.RuntimeException: java.lang.RuntimeException: Field b4xplusminus1 was declared with the wrong type.
        at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:
    170)
        at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:
    209)
        at b4a.exampleggsdg.main._activity_create(main.java:
    348)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    196)
        at b4a.exampleggsdg.main.afterFirstLayout(main.java:
    104)
        at b4a.exampleggsdg.main.access$
    000(main.java:17)
        at b4a.exampleggsdg.main$WaitForLayout.run(main.java:
    82)
        at android.os.Handler.handleCallback(Handler.java:
    873)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    193)
        at android.app.ActivityThread.main(ActivityThread.java:
    6863)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    858)
    Caused by: java.lang.RuntimeException: Field b4xplusminus1 was declared with the wrong 
    type.
        at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:
    431)
        at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:
    454)
        at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:
    148)
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Using XUI Views v2.05?
     
  4. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    yes, downloaded 5 mins. ago.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the unfiltered logs?

    Have you copied it to the internal libraries folder?
     
  6. Mahares

    Mahares Well Known Member Licensed User

    I downloaded: B4X Views but the library pane still shows: version 2.00 after refresh
    EDIT: I had it in the additional lib folder. All is good now
     
    Erel likes this.
  7. Erel

    Erel Administrator Staff Member Licensed User

     
    Mahares likes this.
  8. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Yes
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Please compile the program in release mode and upload the APK.
     
  10. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

     

    Attached Files:

    • 1.apk
      File size:
      334.1 KB
      Views:
      39
  11. Erel

    Erel Administrator Staff Member Licensed User

    Where does b4a.exampleggsdg come from?
    Which version of B4A are you using? Try to clean the project (Ctrl + P).
     
  12. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    i downloaded the example project above, change the paketname to this, because i have a other paket with "b4a.example" on the phone.

    9.00
     
  13. Erel

    Erel Administrator Staff Member Licensed User

  14. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

  15. RWK

    RWK Member Licensed User

    Got it working in B4J

    Code:
    Sub Process_Globals
        
    Private fx As JFX
        
    Private mainForm As Form
        
    Private B4XPlusMinus1 As B4XPlusMinus
        
    Private B4XPlusMinus2 As B4XPlusMinus
        
    Private B4XPlusMinus3 As B4XPlusMinus
        
    Private B4XPlusMinus4 As B4XPlusMinus
    End Sub

    Sub AppStart (Form1 As Form, Args() As String)
        mainForm = Form1
        mainForm.RootPane.LoadLayout(
    "frmMain"'Load the layout file.
        mainForm.Show
        
        B4XPlusMinus1.SetStringItems(
    File.ReadList(File.DirAssets, "cities.txt"))
        B4XPlusMinus1.Increment
        
        
    Dim clrs As List
        clrs.Initialize
        clrs.Add(
    "Red")
        clrs.Add(
    "Green")
        clrs.Add(
    "Blue")
        B4XPlusMinus2.SetStringItems(clrs)
        B4XPlusMinus2.SelectedValue = clrs.Get(
    0)
        B4XPlusMinus3.SetNumericRange(
    01001)
        B4XPlusMinus4.Formatter.GetDefaultFormat.MaximumFractions = 
    2
        B4XPlusMinus4.Formatter.GetDefaultFormat.MinimumIntegers = 
    2
        B4XPlusMinus4.Formatter.GetDefaultFormat.MinimumFractions = 
    2
        B4XPlusMinus4.SetNumericRange(
    0101 / 3)
    End Sub
    Is the expected way to copy the b4x internal lib in each of the internal libraries folder...b4a, b4j, b4i
    or better to remove internal libraries and put it in additional b4x ?

    Ähmm....Nope Question:
    How to assign b4xPlusMinus1 directly to the....say... third city in this case?

    Grüße
    Rainer
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Yes. The good news is that the latest version will be included when the IDE is updated.

    Code:
    Dim cities As List = File.ReadList(File.DirAssets, "cities.txt")
    B4XPlusMinus1.SetStringItems(cities)
    B4XPlusMinus1.SelectedValue = cities.Get(
    2)
     
  17. Roberto P.

    Roberto P. Well-Known Member Licensed User

    it would be interesting to add long press for automatic increased or decreised.
     
  18. jimmyF

    jimmyF Active Member Licensed User

    It's there already! Press and hold, in the sample from the first post
     
    Erel likes this.
  19. Erel

    Erel Administrator Staff Member Licensed User

     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice