B4A Library ValueBar V1.0.1

This is a Wrapper for this github Project.

You need to download the newest jar file from the Authors releasesection here.
Download the file valuebarlibrary-1-0-2.jar and put it into your Additional libs folder.

Additionally download the Libraryfiles from this Post and put them into the additional libs folder too.

ValueBar
Version:
1.01
  • ValueBar
    Events:
    • onselectionupdate (val As Float, maxval As Float, minval As Float, Tag As Object)
    • onvalueselected (val As Float, maxval As Float, minval As Float, Tag As Object)
    Fields:
    • ba As BA
    Methods:
    • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • animate (from As Float, to As Float, animationDuration As Int)
      Animates the bar from a specific value to a specific value.
    • animateDown (to As Float, durationMillis As Int)
      Animates the bar down from it's current value to the specified value.
    • animateUp (to As Float, durationMillis As Int)
      Animates the bar up from it's minimum value to the specified value.
    • getValueForPosition (xPos As Int) As Float
      Returns the corresponding value for a pixel-position on the horizontal
      axis.
    • isDrawMinMaxTextEnabled As Boolean
      Returns true if drawing the minimum and maximum label is enabled.
    • isDrawValueTextEnabled As Boolean
      Returns true if drawing the text that describes the actual value is
      enabled.
    • setMinMax (min As Float, max As Float)
      Sets the minimum and maximum value the bar can display.
    Properties:
    • Background As Drawable
    • BackgroundColor As Int [write only]
    • BorderColor As Int [write only]
      Sets the color of the border around the bar (if drawn).
    • BorderWidth As Float [write only]
      Sets the width of the border around the bar (if drawn).
    • Color As Int [write only]
      Sets the color the ValueBar should have.
    • ColorFormatter As Boolean [write only]
      Sets a custom BarColorFormatter for the ValueBar. Implement the
      BarColorFormatter interface in your own formatter class and return
      whatever color you like from the getColor(...) method. You can for
      example make the color depend on the current value of the bar. Provide
      null to reset all changes.
    • DrawBorder As Boolean [write only]
      Set this to true to enable drawing the border around the bar, or false to
      disable it.
    • DrawMinMaxText As Boolean [write only]
      Set this to true to enable drawing the minimum and maximum labels below
      the bar.
    • DrawValueText As Boolean [write only]
      Set this to true to enable drawing the actual value that is currently
      displayed onto the bar.
    • Enabled As Boolean
    • Height As Int
    • Interval As Float [write only]
      Sets the interval in which the values can be chosen and dispalyed from
      on the ValueBar. If interval <= 0, there is no interval.
    • Left As Int
    • Max As Float [read only]
      Returns the maximum value the bar can display.
    • Min As Float [read only]
      Returns the minimum value the bar can display.
    • MinMaxTextSize As Float [write only]
      Sets the size of the min-max text in density pixels.
    • MinMaxTextTypeface As Typeface [write only]
      Sets the Typeface of the min-max text.
    • OverlayColor As Int [write only]
      Sets the color of the overlay that is placed below the value-text.
    • Tag As Object
    • Textformat As String [write only]
    • Top As Int
    • Value As Float
      Returns the currently displayed value.
    • ValueTextSize As Float [write only]
      Sets the size of the value-text in density pixels.
    • ValueTextTypeface As Typeface [write only]
      Sets the Typeface of the value-text.
    • Visible As Boolean
    • Width As Int

Example code can look like this (assuming you have added the bars via Designer

B4X:
Sub Globals
    Private vb1 As ValueBar
    Private vb2 As ValueBar
    Private vb3 As ValueBar
    Private t1 As Timer
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    vb1.Textformat = "###,###,##0"
    vb1.Color = Colors.Red
    vb1.OverlayColor = Colors.Blue
    vb1.BackgroundColor = Colors.LightGray
    vb1.DrawBorder = True
    vb1.Interval = 10
    vb1.setMinMax(0,100)
    vb1.animate(0,80,5000)
    vb1.Tag = 1

    vb2.Textformat = "###,###,##0.0"
    vb2.Color = Colors.Red
    vb2.OverlayColor = Colors.Green
    vb2.BackgroundColor = Colors.LightGray
    vb2.DrawBorder = True
    vb2.Interval = 10
    vb2.setMinMax(0,10)
    vb2.animate(0,7.5,1000)
    vb1.Tag = 2


    vb3.Textformat = "###,###,##0.00"
    vb3.OverlayColor = Colors.Yellow
    vb3.BackgroundColor = Colors.DarkGray
    vb3.DrawBorder = True
    vb3.Interval = 10
    vb3.setMinMax(0,100)
    vb3.animate(0,69.95,1000)
    vb3.Tag = 3

    t1.Initialize("timer",2000)
    t1.Enabled = True
End Sub
Sub timer_tick
    If vb3.Value < (vb3.Max/2) Then
        Dim rndNum As Int = Rnd(50, 101)
        vb3.animateUp(rndNum,1000)
    Else
        Dim rndNum As Int = Rnd(0, 50)
        vb3.animateDown(rndNum,1000)
    End If
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub vb_onselectionupdate(val As Float, maxval As Float, minval As Float, tag As Object)
    Log("vb_onselectionupdate(bar "&tag&","&val&","&maxval&","&minval&")")
End Sub



This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
Please click here to donate for my work to write the wrapper (You can donate any amount you want :))


Please consider to donate to the Original Author of this Library, Philip Jahoda, too! See Donatebutton here.

I just wrote the Wrapper for this Library so it can be used in our beloved B4A :D
 

Attachments

  • libValueBarV1.0.0.zip
    9.7 KB · Views: 400
  • ValueBarEx.zip
    12.4 KB · Views: 482
  • libValueBarV1.0.1.zip
    9.8 KB · Views: 517
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Updated to V1.0.1
Forgot the OnValueSelected event
Library can be found on #1
 

Mahares

Expert
Licensed User
Longtime User
I tried to use an increment that is decimal say .5, but it only jumps 1 at a time:
B4X:
vb2.Textformat = "0.0"
    vb2.setMinMax(0,10)
    vb2.Interval = .5

1. Thank you @DomManfred. It is amazing what you have been putting out lately in terms of libraries.
2. I hope you will not desert us like some that created some libraries and are no longer supporting them or no longer members of the forum.
3. Do you have one link that brings up exclusively all you libraries in one place?
4. Do you have plans to create a library for the Date picker as you did for the time picker?
5. I hope you are better looking than your avatar.
 

DonManfred

Expert
Licensed User
Longtime User
1. Thank you @DomManfred. It is amazing what you have been putting out lately in terms of libraries.
you are welcome :)
2. I hope you will not desert us like some that created some libraries and are no longer supporting them or no longer members of the forum.
I hope that too ;)
3. Do you have one link that brings up exclusively all you libraries in one place?
I got a login to the wiki lately... Will do an overview there when i have time
4. Do you have plans to create a library for the Date picker as you did for the time picker?
A Datepicker to select date with an circular Clock? Maybe i misunderstood
Do you find a suiteable here?
5. I hope you are better looking than your avatar.
Insignificant :D
 

DonManfred

Expert
Licensed User
Longtime User
I tried to use an increment that is decimal say .5, but it only jumps 1 at a time:
B4X:
    vb2.Textformat = "###,###,##0.0"
    vb2.Color = Colors.Red
    vb2.OverlayColor = Colors.Green
    vb2.BackgroundColor = Colors.LightGray
    vb2.DrawBorder = True
    vb2.Interval = 10
    vb2.setMinMax(0,10)
    vb2.animate(0,7.5,10000)
i used this and this counts in 0.1 steps... I really dont have understand the system here too actually ;)
 

Johan Schoeman

Expert
Licensed User
Longtime User

ArminKH

Well-Known Member
See post #1. There is a library that you need to download and that you then have to add to your additional library folder.
ooooops sorry
thank u , i just looking for that in attached files:D
 

rbtcotton

Member
Licensed User
Longtime User
Great value bar!

I have 3 questions.
1.) How to set the bar where the user cannot change the values by touching the bar after the bar is display?
2.) Can the text in the bar be rotated ?
3.) The colors that are define in the app are not the colors on the display?

Much thanks in advance
 
Top