Android Question Changes in the view on another B4Xpage

SMOOTSARA

Active Member
Licensed User
Longtime User
Hi guys ?

I use the b4xpage library

I have defined two pages

1-B4XMainpage
2-SecondPageClass

I want to change the background color (or view) of "SecondPageClass"from "B4XMainpage"
But after creating the "SecondPageClass" I can not do this
How do I affect a view in "SecondPageClass"?
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
One way it to create a method on SecondPageClass to do what you want and then call that from B4xMainPage.

in SecondPageClass
B4X:
public sub changeme(clr as int)
vw.color = clr
end sub

in MainPage
B4X:
'assuming the identifier for second page class is secondpageclass
private sc as SecondPageClass = B4xPages.getPage("SecondPageClass")
sc.changeme(colors.red)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Creating a sub for this is possible but not needed.

Make SecondPageClass variable public:
B4X:
Dim sc as SecondPageClass = B4xPages.getPage("SecondPageClass")
sc.ASecondPageClass.DoSomething
In such cases it is usually a good idea to add the page with B4XPages.AddPageAndCreate. This way you don't need to worry about the second page layout not being created when you want to manipulate it.
 
Upvote 0
Top