B4A Library NumberProgressBar V3

This is a wrapper for this Github-project.
This is a complete rewrite of the wrapper as i lost the source by accident.
V2 includes CustomProperties for the Designer.

NumberProgressBar
Author:
DonManfred (wrapper)
Version: 3
  • NumberProgressBar
    Events:
    • onProgressChange (current As Int, maxvalue As Int)
  • Fields:
    • ba As BA
  • Methods:
    • 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)
    • dp2px (dp As Float) As Float
    • incrementProgressBy (by As Int)
    • sp2px (sp As Float) As Float
  • Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Max As Int
    • Parent As Object [read only]
    • Prefix As String
    • Progress As Int
    • ProgressTextColor As Int
      progress text color.
    • ProgressTextSize As Float
      progress text size.
    • ProgressTextVisible As Boolean
    • ReachedBarColor As Int
    • ReachedBarHeight As Float
    • Suffix As String
    • Tag As Object
    • Top As Int
    • UnreachedBarColor As Int
    • UnreachedBarHeight As Float
    • Visible As Boolean
    • Width As Int

687474703a2f2f7777332e73696e61696d672e636e2f6d773639302f36313064633033346a77316566797264386e376937673230637a30326d7135662e676966


Code used in Example
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private np1 As NumberProgressBar
    Private np2 As NumberProgressBar
    Private np3 As NumberProgressBar
    Dim t1, t2, t3 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")
    np1.incrementProgressBy(0)
    np1.ProgressTextColor = Colors.Blue
    np1.ReachedBarColor = Colors.Yellow
    np1.UnreachedBarColor = Colors.Red
    np1.UnreachedBarHeight = 1dip
    np1.ReachedBarHeight = 5dip
    np1.Prefix = "%"
    np1.Suffix = ""
    t1.Initialize("t1",50)
    t1.Enabled = True

    np2.incrementProgressBy(0)
    np2.ProgressTextColor = Colors.White
    np2.ReachedBarColor = Colors.Green
    np2.UnreachedBarColor = Colors.Red
    np2.UnreachedBarHeight = 5dip
    np2.ReachedBarHeight = 5dip
    t2.Initialize("t2",60)
    t2.Enabled = True

    np3.incrementProgressBy(0)
    np3.ProgressTextColor = Colors.Green
    np3.ReachedBarColor = Colors.Magenta
    np3.UnreachedBarColor = Colors.LightGray
    np3.UnreachedBarHeight = 5dip
    np3.ReachedBarHeight = 1dip
    np3.Prefix = "Prefix"
    np3.Suffix = "Suffix"
    t3.Initialize("t3",100)
    t3.Enabled = True
End Sub
Sub t1_tick
    If np1.Progress <= 100 Then
        np1.incrementProgressBy(1)
    Else
        t1.Enabled = False
    End If
End Sub
Sub t2_tick
    If np2.Progress <= 100 Then
        np2.incrementProgressBy(1)
    Else
        t2.Enabled = False
    End If
End Sub
Sub t3_tick
    If np3.Progress <= 100 Then
        np3.incrementProgressBy(1)
    Else
        t3.Enabled = False
    End If
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 (You can donate any amount you want to donate for the library (or my work) :)
 

Attachments

  • NumberProgressBar_example.zip
    21.6 KB · Views: 414
  • NumberProgressBarV3.0.zip
    13.8 KB · Views: 423
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Is possible start by 100 and decrement to go at 0?

Where is the problem?


Old
B4X:
Sub t1_tick
    If np1.Progress <= 100 Then
        np1.incrementProgressBy(1)
    Else
        t1.Enabled = False
    End If
End Sub

New
B4X:
Sub t1_tick
    If np1.Progress > 0 Then
        np1.Progress = np1.Progress -1
    Else
        t1.Enabled = False
    End If
End Sub

Dont forget to start at 100 instead of 0
B4X:
    np1.Progress = 100
 

luciano deri

Active Member
Licensed User
Longtime User
Where is the problem?


Old
B4X:
Sub t1_tick
    If np1.Progress <= 100 Then
        np1.incrementProgressBy(1)
    Else
        t1.Enabled = False
    End If
End Sub

New
B4X:
Sub t1_tick
    If np1.Progress > 0 Then
        np1.Progress = np1.Progress -1
    Else
        t1.Enabled = False
    End If
End Sub

Dont forget to start at 100 instead of 0
B4X:
    np1.Progress = 100
ok Grazie.
 

luciano deri

Active Member
Licensed User
Longtime User
Is possible make a max value otherwise at 100 and see this true number? I have done so
B4X:
pvpers = 60
CVpvpers.Max=pvpers
CVpvpers.Progress = pvpers
I vould like see a full bar but text value = 60
 

delozoya

Member
Licensed User
Longtime User
Hello, Thanks for your works.
Is it possible to replace the number with the% , for a icon?
 

ArminKH

Well-Known Member
is this possible to set ProgressText background color to transparent? that is always white
 

DonManfred

Expert
Licensed User
Longtime User
is this possible to set ProgressText background color to transparent?
i´ll release a new version later today (hopefully) where you can set a background-color. The original lib does not set any... my first tryings (hardcoded) work. Need to write some code to include it into the lib...

Edit: I looked at the result and thought; hmm, this looks like before!?
So i removed my changes and try again....

Same result. One of the bars in example showed a white unreachedbar... I´ll investigate more on this
 
Last edited:

ArminKH

Well-Known Member
i´ll release a new version later today (hopefully) where you can set a background-color. The original lib does not set any... my first tryings (hardcoded) work. Need to write some code to include it into the lib...

Edit: I looked at the result and thought; hmm, this looks like before!?
So i removed my changes and try again....

Same result. One of the bars in example showed a white unreachedbar... I´ll investigate more on this
anyway thank u for your hard work fred ;)
 

Dave O

Well-Known Member
Licensed User
Longtime User
Nice library. I was looking for a progress bar that let me set the max # and have more control over the visuals, and this does the job.

Wish: Ability to set more properties in the designer instead of in code.

Will donate now. Cheers!
 

DonManfred

Expert
Licensed User
Longtime User
Wish: Ability to set more properties in the designer instead of in code.
I´ll write another wrap for this as i accidently lost my wrap-source.

Not a big deal.
Will release it later today. Including B4A 5.8 Designerproperties. (Note i rewrote the wrapper in about 20 minutes now; but i need some additional time to add Designerproperties :) )

But for now i need to go shopping as we want to have BBQ in the evening...
 

Dave O

Well-Known Member
Licensed User
Longtime User
Just tried v2, but get an error on:

searchPB.ProgressTextVisibility = False

(where searchPB is the progress bar):

error: incompatible types: boolean cannot be converted to ProgressTextVisibility
 

DonManfred

Expert
Licensed User
Longtime User
searchPB.ProgressTextVisibility
i changed this method to expect boolean. Additional i changed the Propertxname from ProgressTextVisibility to ProgressTextVisible
B4X:
searchPB.ProgressTextVisible = false
should work now

See #1 for Updated lib V2.1.0
 

Dave O

Well-Known Member
Licensed User
Longtime User
Yes, that works, although the code auto-suggest now shows ProgressTextVisible as write-only and ProgressTextVisibility as read-only. Is that intentional, or did you forget to rename the getter method?

Also, it would be nice to have ProgressTextVisible settable in the designer too.

But in the meantime, nice control - definitely made my app better. Thanks! :)
 

DonManfred

Expert
Licensed User
Longtime User
Top