B4A Library [Class] ICS Like Horizontal and Vertical Seekbars

This class implements ICS Like SeekBars.

Every seekbar is drawn when created so you can set :
- color and size of the button
- color and width of the stroke
- choose if value is shown or not
- choose where is the max value for the vertical one (up or down)
- set the max value and the start value
- enable/disable

Requirements:
- B4A 2.xx
- ABExtDrawing Lib

How to use (example for the horizontal one):

Initialize the class :
B4X:
Sub Globals
   Dim SBT1 As mbHSeekBar
End Sub

then create it :
B4X:
'Activity, Module,EventName,Left,Top,Width,Height,StrokeWidth,StrokeDefautColor,Color,TextVisible,InitValue,MaxValue
SBT1.Initialize(Activity,Me,"SBT_Click",1%x,10%y,98%x,52dip,5dip,Colors.DarkGray,Colors.RGB(0xcc,0x00,0x00),True,200,255)

(Don't forget to add True or False at the end if ou use the vertical class to choose where must be the max value, at the top or the bottom)

You can customize the text showing the value:
B4X:
SBT1.CustomizeText(Colors.Red,22,Typeface.DEFAULT_BOLD)

You can set a value at any time:
B4X:
SBT1.setValue(33)

You can set a step value:
B4X:
SBT1.stepValue = 10 ' value will be rounded from 10 to 10

in the main activity you can get the selected value:

B4X:
Sub SBT_Click(returnValue)
   Activity.Title = "Value is " & returnValue    
End Sub

That's it. Have a look at the demos and send feedback or ideas for enhancements.
 

Attachments

  • demoh.png
    demoh.png
    32.3 KB · Views: 1,010
  • demov.png
    demov.png
    32.1 KB · Views: 881
  • ICSLike_SeekBars.zip
    14.8 KB · Views: 816
Last edited:

Taylor Chapman

Member
Licensed User
Longtime User
These are great! Thanks!

I'm wondering how to create a horizontal bar alike to the third one down in your picture (a balance bar). How can I make the "trail" of the seekbar the same color as the "leading" part?

I'd appreciate any help you can offer!
 

migrec

Member
Licensed User
Longtime User
I got a small problem here, isn't mbhseekbar.maxvalue the same thing as seekbar.max?
 

JTmartins

Active Member
Licensed User
Longtime User
I would like to handle values from - X to + X.

Help Would be appreciated.

****SOLVED****
 
Last edited:

Marvin Januszewski

New Member
Licensed User
Longtime User
Very nice ! I will use it to control my home heating!

But one question...how can I set a minimum value? That would be very nice!
 

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Thanks for this well customizable class !
I used it for making the dual-side slider, range selection, for MinValue and MaxValue, try if you'd like.
 

Attachments

  • dualslider.png
    dualslider.png
    7.1 KB · Views: 216
  • mbHSeekBar2.zip
    2.3 KB · Views: 224
Top