Android Question [B4X] Custom View cause a error if the user input a wrong variable

Alexander Stolte

Expert
Licensed User
Longtime User
Hello,

i make a new custom view and i have a "CustomView Property" witch i want to change in the code, the type of this Property is String in a list.
The User has 3 Options to choose in the designer, now i want to cause a error in the IDE if the user type a wrong input in this variable, is this possible?

Greetings
 

Alexander Stolte

Expert
Licensed User
Longtime User
How is the custom property defined in your code?
B4X:
#DesignerProperty: Key: Icon_direction, DisplayName: Icon Direction, FieldType: String, DefaultValue: LEFT, List: LEFT|MIDDLE|RIGHT
and i load this in a string on view create.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
... if the user type a wrong input in this variable, is this possible?
Yes, it is possible.
You need to define a Property in the code, like:
B4X:
Public Sub setMyProperty(MyProperty As String)
    If MyProperty = Option1 Or MyProperty = Option2 Or MyProperty = Option3 Then
        mMyProperty = MyProperty 'class internal variable
        'other code
    Else
        MsgBox(....
    End If
End Sub

Public Sub getMyProperty As String
    Return MyProperty
End Sub
In the main code:
MyCustomView.MyProperty = xxx

All this is explained in the B4X CustomViews Booklet.
 
Upvote 0
Top