B4J Question Remove a background image ?

hookshy

Well-Known Member
Licensed User
Longtime User
I did set up a background image for a tabpane ...wow

Q: I did not manage to remove it . How do you remove background image once set ?

I tried : page.content.Style="" but did not worked

B4X:
    Dim page As TabPage
    page=station.Tabs.get(i)
    page.Content.Style="-fx-background-image: url('" & File.GetUri(File.DirApp, i&".png") & "');"
    page.Content.Style=page.Content.Style&"-fx-background-repeat: stretch;"
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

have tested = add first and then remove as suggested. It works fine.

B4X:
' Set the background image of a TabPane
' Tabpane declared as Private tabMedia As TabPage
tabMedia.Content.Style="-fx-background-image: url('" & File.GetUri(File.DirApp, "background.png") & "');"
tabMedia.Content.Style=tabMedia.Content.Style&"-fx-background-repeat: stretch;"

' Remove the image from the tabpane
tabMedia.Content.Style="-fx-background-image:none"
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
I did try it out ...and yet I do not understand...

From my test ..the above code works only at startup when style is not defined for the tabview page.
If I add a background ...then press another button to set it to none it seems it does not work ...

It does not make sense to add an image just to activate the <none > as key for removing the background .....


If I understand your code it someting like :
dim var as string
var="january"
var ="none"

return var
In this case the function will never return "january"
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I think rwbiinn was pointing out the code to set the image and then the code to remove it. Not that you put the remove image directly after the set image.
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
ot that you put the remove image directly after the set image.
Yes I did that
'same routine works to load a background without ofcourse with the none part
'this is strange because once set the background does not go ....
'first time if you use routine or at startup when no style was set on pane the code works
B4X:
If File.Exists(lastpath,station.SelectedIndex&".png") Then
    Log("remove background")
  
    Dim page As TabPage
    page=station.Tabs.Get(station.SelectedIndex)

    Dim stil As StringBuilder
stil.Initialize
stil.Append("-fx-background-image: url('" & File.GetUri(lastpath, station.SelectedIndex&".png") & "');")
stil.Append("-fx-background-repeat: stretch;")


page.Content.Style=stil.ToString

    page.Content.Style="-fx-background-image:none "
    Log(page.Content.Style) 'the rezult of this log in my log window is : "-fx-background-image:none " but image is still there
  
    'File.Delete(lastpath,station.SelectedIndex&".png")
End If
 
Upvote 0
Top