B4A Library RangeSeekBar Wrapper

Discussion in 'Additional libraries, classes and official updates' started by cimperia, Apr 6, 2015.

  1. cimperia

    cimperia Active Member Licensed User

    Here’s a wrapper for a RangeSeekBar widget I found on GitHub : https://github.com/yahoo/android-range-seek-bar.

    I have modified the original code to suit my needs as it had a couple of issues.

    You can add a RangeSeekBar in the designer, by code or XML layout. It can use as easily Integer or Decimal values. You'll notice that some of the return values are shown as data type T by BA4 intellisense. No worry, just use int if you want integer values, and float for decimal values.

    [​IMG]

    You can initialize a one thumb RangeSeekBar (in effect a SeekBar) or a RangeSeekBar. You can switch from one to the other by changing its propery:

    Code:
    Dim rsb As RangeSeekBar
    .....
    rsb.SingleThumb = 
    True
    To install:

    1. Download the zip file

    2. Copy RangeSeekBar.jar and RangeSeekBar.xml to your shared library folder

    3. Add a reference to RangeSeekBar in your B4A project

    4. Copy the res folder into your project and add a line in your project pointing to the folder on your hard-drive. Leave the package name unchanged.

    Code:
    #AdditionalRes: C:\<YourPath>\testrangeseekbar\res, com.yahoo.mobile.client.android.util;
    There’s a short demo project you can run to see what it all looks like. Make sure you add the resource folder and change the path to it.

    I coded the wrapper and compiled the libraries using Android Studio (AS) in a gradle project, which is now the recommended Google IDE.

    It was a bit of a challenge to produce the jar and XML (javadoc stuff) using Gradle as I had to manipulate Android Studio archive files (aar).

    The toughest part was to produce a gradle task to generate the XML file using the BADoclet.

    However gradle is a very powerful script language to build applications, and from Android Studio I was able, at the click of a button, to automatically compile the sources, merge the jars, create and edit the XML file (replace T parameters with double where relevant) and copy it all into my shared library folder.

    If anyone is interested, let me know and I will post the XML generation code here.

    Enjoy :)

    10.4.2015
    Version 1.0.1

    Added Initialize2 method to initialize a RangeSeekBar instance with range settings and single/double thumb widget in one call.

    Added property to hide numbers above thumbs.

    Added property to change colour of numbers above thumbs.

    Added property to change labels colour.

    Edit: 23/3/2016
    Posted java library code & java wrapper code.
     

    Attached Files:

    Last edited: Mar 23, 2016
    luke2012, scsjc, wineos and 9 others like this.
  2. cimperia

    cimperia Active Member Licensed User

    10.4.2015
    Version 1.0.1

    After using this library in one of my own project, I've added a bit of functionality that it was lacking.

    • Added Initialize2 method to initialize a RangeSeekBar instance with range settings and single/double thumb widget in one call.
    • Added property to hide numbers above thumbs.
    • Added property to change colour of numbers above thumbs.
    • Added property to change labels colour.
     
    Last edited: Apr 10, 2015
  3. giga

    giga Well-Known Member Licensed User

    Nice work, thanks for sharing. :)
     
    cimperia likes this.
  4. PABLO2013

    PABLO2013 Active Member Licensed User

    tks ,
    regards
    1. How to change the width of the bar
    2. as changing values in integers and not in decimals
    3 could add circles or other patterns to suggest values
    you would bar the most complete



    tks in advanced
     

    Attached Files:

  5. cimperia

    cimperia Active Member Licensed User

    If you download the example you'll see answers to your points 1 & 2.

    As far as suggested values are concerned I have no plan to add them (lack of time). I could post the Java & wrapper code if you want to tackle it yourself?
     
    Last edited: Mar 22, 2016
  6. scsjc

    scsjc Active Member Licensed User

    Hello, nice work !!!!
    is possible change color line (now is blue and darkgray)

    thanks !!!
     
  7. cimperia

    cimperia Active Member Licensed User

    Yes it is. I have posted the source and wrapper java code, so you can modify to your heart's content ;)
     
    DonManfred likes this.
  8. scsjc

    scsjc Active Member Licensed User

    ok, and another question, i dont know take off decimals, always show. can force without decimals on bar ?
    Screenshot_20160919-232603.png
     
  9. cimperia

    cimperia Active Member Licensed User

    If you study the demo, you'll see that it shows decimal bars and integer bars.
     
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