Logic to Programmatically Set a Property Value at Run Time
Many properties allow you to specify a method name as the property value. At run time, the application executes the method to determine the property value. For example, you might want to programmatically determine the color to use for the Background Color property for a Tablerow object. To do so, specify the name of the method that sets the color as the value of the Background Color property.
At run time, no input parameters will be passed to the method. The output from the method must be a suitable value for the property. For example, if you are using a method for a color, the output must be a value that specifies a color in a suitable format.
Where you place the code for the method depends on whether you specified a relative method name or a fully-qualified method name for the property value.
Relative method name When you specify a relative method name,
Mobile Development generates the method in the abstract controller for the associated view. The actions you take to add logic to the method are the same as when you use a
Method Name property. For more information, see
Logic for a Method Name Property.
Fully-qualified name When you specify a fully-qualified method name, the method you specify must exist in a Java class you create. It is recommended that you save the Java class in a location within the project’s src folder so that all the code you maintain is in one folder.
Ensure the methods that you create are static so that no instance of the class needs to be in existence.
Related Topics