Android Question how to use B4XPreferenceDialog in B4XPages

tsteward

Well-Known Member
Licensed User
Anyone got a quick example on using B4XPreferences in a B4XPages project.
The examples on the page only show usage on a normal app.
 

aeric

Expert
Licensed User
I don’t think any different or maybe change the Parent to Root when Initialize.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Do I create the prefereancedialog in the Main activity or in B4XMainPage?
Then if in B4XMainPage when initializing what do I put for activity?

In B4J I have created it in B4XMainPage then to initialize I do this which all works well
prefdialog.Initialize(Main.MainForm.RootPane,"Preferences",400dip,400dip)

But I can't figure out how to do it in B4A with B4XPages
 
Upvote 0

ShaneG30

Well-Known Member
Licensed User
Do I create the prefereancedialog in the Main activity or in B4XMainPage?
Then if in B4XMainPage when initializing what do I put for activity?

In B4J I have created it in B4XMainPage then to initialize I do this which all works well
prefdialog.Initialize(Main.MainForm.RootPane,"Preferences",400dip,400dip)

But I can't figure out how to do it in B4A with B4XPages

You're not supposed to use "Main.MainForm.RootPane" in B4XPages. You instead use "Root", with a PreferencesDialog variable declared in each page that needs a Preference Dialog. So for example:

B4X:
'Class_Globals:
Sub Class_Globals
    Private PrefDialog As PreferencesDialog
End Sub

'Later:
Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("YourLayoutFile")
    PrefDialog.Initialize(Root,"Preferences",400dip,400dip)
End Sub
 
Upvote 0

tsteward

Well-Known Member
Licensed User
You're not supposed to use "Main.MainForm.RootPane" in B4XPages. You instead use "Root", with a PreferencesDialog variable declared in each page that needs a Preference Dialog. So for example:

B4X:
'Class_Globals:
Sub Class_Globals
    Private PrefDialog As PreferencesDialog
End Sub

'Later:
Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("YourLayoutFile")
    PrefDialog.Initialize(Root,"Preferences",400dip,400dip)
End Sub
Thank you, I swear I tried that and it didn't work but it is now :D
 
Upvote 0
Top