Android Question B4XSeekBar: How can I enable/disable it in code?

rgarnett1955

Active Member
Licensed User
Longtime User
Hi,

I've made a navigation bar for controlling the time axis of charts.

I tried:

B4X:
    timeSeek.mBase.GetView(0).Enabled = enabledArg

But this didn't work.

NavBarWithSlider.png



I have included a very nice B4XSeekBar, but I need to be able to enable/disable it in code. Also visibility control would be useful.

These properties are exposed in the designed, but not in code. Is it possible to do this in some way.

Best regards
Rob
 
Last edited:

rgarnett1955

Active Member
Licensed User
Longtime User
B4X:
B4XSeekBar1.mBase.Visible=false
Not sure if you can enable/disable. Maybe set the min and max values to the same value:
B4X:
B4XSeekBar1.MinValue=0 'or any other vavue
    B4XSeekBar1.maxValue=0

Hi Mahares,

Good idea, Thanks for that.

Not a complete solution as the seek bar will not be shown disabled, but I will give this a try.

I wish people who program these libraries would include the Enabled and Visibility properties for coding. For even simple apps this is essential.

Having these properties exposed in the designer is pointless if you don't include them in the code. For any view you would have to set enabled and visible to True, otherwise you could never use the view. If you set visibility to False in the designer how are you supposed to make the view Visible when you need it?

Best regards
Rob
 
Upvote 0

rgarnett1955

Active Member
Licensed User
Longtime User
Hi Mahares,

Good idea, Thanks for that.

Not a complete solution as the seek bar will not be shown disabled, but I will give this a try.

I wish people who program these libraries would include the Enabled and Visibility properties for coding. For even simple apps this is essential.

Having these properties exposed in the designer is pointless if you don't include them in the code. For any view you would have to set enabled and visible to True, otherwise you could never use the view. If you set visibility to False in the designer how are you supposed to make the view Visible when you need it? Beats me!

Best regards
Rob

Hello Again,

It turns out if you do this:

B4X:
timeSeek.mBase.GetView(1).Enabled = enabledArg

Note that rather than use GetView(0) which works for B4Xcombo boxes you have to use GetView(1) for the seek bar.

This also works:

B4X:
    For Each v As B4XView In timeSeek.mBase.GetAllViewsRecursive
        v.Enabled = enabledArg
    Next

It works although there is no indication that the seek bar is disabled.

Sometimes B4X drives me nuts.

Best regards
Rob
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I wish people who program these libraries would include the Enabled and Visibility properties for coding.

As @Mahares suggested above .. just access the Base Panel (mBase) that contains the custom view


For any view you would have to set enabled and visible to True,
Again .. just access the property via mBase.

B4X:
    B4XSeekBar1.mBase.Enabled = False
    B4XSeekBar1.mBase.Visible = True

I do agree there is no visual hint the view is disabled ... might have to play with bar colors to make this so.
 
Upvote 0
Top