Android Question How to get Custom View's Custom Properties from Code

Anser

Well-Known Member
Licensed User
Longtime User
I found that many properties of the view, available while we add a view through the designer, is not available when we add a view by code.
OR
How do I get the Custom properties available in the designer when we add views by code

For eg. When I add a CustomListView thru designer, I get the Custom Properties like Divider Color, Divider Height, PressedColor etc. Unfortunatley these properties are not available when I add a CustomListView by code

Am I doing anything wrong ? OR is this the expected way.

Regards
Anser
 

klaus

Expert
Licensed User
Longtime User
You need to add routines in the customview class code like:
B4X:
'gets the DeviderColor property
Public Sub getDeviderColor As Int
    Return MyDeviderColor
End Sub

'sets the DeviderColor property
Public Sub setDeviderColor(DeviderColor As Int)
    MyDeviderColor = DeviderColor 
    ' and other code to set the color to the given view
End Sub
Routines beginning with get (lower case) define read properties and routines beginning with set (lower case) define write properties.
The text after get and/or set is the property name.

You may have a look at chapters
12.4 Custom views
and more specific
12.4.3 Add properties
in the B4A User's Guide.
 
Last edited:
Upvote 0
Top