B4J Question Property _loadlayout is writeonly

Alexander Stolte

Expert
Licensed User
Longtime User
Hello, i have a problem, i want to set a "LoadLayout" property for my new view.
I have this code:
B4X:
'set the layout for designer
Public Sub setLoadLayout(layout As LayoutValues)
   
    mypnl.LoadLayout(layout.toString)
   
End Sub

The IDE Log says:
B4X:
Property: _loadlayout is writeonly.

How can i solve this, so the user can call myview.loadlayout("")
and then he have the selection of the forms?
 

klaus

Expert
Licensed User
Longtime User
This is a write only property, because of the 'set' prefix.
B4X:
Public Sub setLoadLayout(LayoutName As String)
    mypnl.LoadLayout(LayoutName)
End Sub
This is a method:
B4X:
Public Sub LoadLayout(LayoutName As String)
    mypnl.LoadLayout(LayoutName)
End Sub
In this example, both do the same, but to me it's more logical to use a method.

Why do you want to use LayoutValues?
mypnl.LoadLayout expects the layout name as a string.
 
Upvote 0
Top