Android Question B4XPreferencesDialog has a problem with B4XPages ?

Phayao

Active Member
Licensed User
Longtime User
Hello,

When I implement the B4XPreference dialog in the B4Xmainpage, I get the following error when I reach the line

B4X:
    Wait For (prefdialog.ShowDialog(Options1, "OK", "CANCEL")) Complete (Result As Int)

with the error:
Error occurred on line: 95 (B4XDialog)
java.lang.ClassCastException: com.cs.pref1.b4xmainpage cannot be cast to android.view.View

Line 95 is obviously not a code line, but must be somewhere else (?)

Someone had a similar problem ? I am stuck - help is very much appreciated.

Thanks,

Chris
 

Blueforcer

Well-Known Member
Licensed User
Longtime User
how did you initialize the B4XDialog?
You need to initialize it with the root panel of the B4Xpage
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
How anyone help with only one line of code?

According to the error message he initialized the B4XDialog with the B4Xpage like
B4X:
Dim Dialog As B4XDialog
Dialog.Initialize(Me)

But it should be

B4X:
Dim Dialog As B4XDialog
Dialog.Initialize(Root)
If hes working inside a B4XPage
 
Last edited:
Upvote 1

Phayao

Active Member
Licensed User
Longtime User
Hello,

Sorry, I used the definitions in the preferences dialog example:
B4X:
Dim prefdialog as Preferencesdialog
how did you initialize the B4XDialog?
You need to initialize it with the root panel of the B4Xpage
Thank you, that was the mistake ! I used "me" instead of "root"
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…