B4J Question How to display text inside a progressbar?

Mashiane

Expert
Licensed User
Longtime User
Hi there

I'm using a progress bar control and would like it to reflect the percentage provided. How can I go about doing that? Also perhaps could be some functionality to change its background color not to be the default blue?

ProgressBar.png


Thanks a lot..
 

Star-Dust

Expert
Licensed User
Longtime User
If you anchor a label with transparent bottom above the bar progress?
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Hi there

I'm using a progress bar control and would like it to reflect the percentage provided. How can I go about doing that? Also perhaps could be some functionality to change its background color not to be the default blue?

View attachment 65615

Thanks a lot..

B4X:
ProgressBar1.style="-fx-box-border: black; -fx-accent: red;"

I am advocating to progress the progressbar using a thread separate from the mainform, but I resolve, you have an example
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Addition to Post #4 - CustomView ProgressBarIndicator

Scribbled the solution shared Post #4 further to a CustomView which could be used for a customized TableView as in Post #1.

Note: The ProgressBarIndicator Customview is rather simple i.e. beside setting the progress value 0 - 1 (shown in the label as 0 - 100%), there are two properties to set the progressbar and the label text color ... so open for enhancements.

Example attached.
upload_2018-4-23_19-33-9.png
 

Attachments

  • B4JHowToProgressBarIndicator.zip
    5.4 KB · Views: 330
Last edited:
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
this example seems easier to use

B4X:
Sub progress(value As Int)
    If value < 25 Then
        ProgressBar1.style="-fx-box-border: black; -fx-accent: green;"
    else If value > 25 And value < 50 Then
        ProgressBar1.style="-fx-box-border: black; -fx-accent: yellow;"
    else if value > 50 And value < 75 Then
        ProgressBar1.style="-fx-box-border: black; -fx-accent: orange;"
    Else
        ProgressBar1.style="-fx-box-border: black; -fx-accent: red;"
    End If
    ProgressBar1.Progress = value/100
End Sub
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
value < 50
else if value > 50

When value = 50 - accent will be red... ( I often forget "<=" as well )
Otherwise, yes...
 
Last edited:
Upvote 0
Top