I hava problem when create FloatLabeledEditText with code.
Message Error
java.lang.RuntimeException: Object should first be initialized (FloatLabeledEditText).
My code is like this ...
B4X:
' The hosting panel for B4XView
Dim p As Panel
' The b4xview control
Dim xV As B4XView
' Add the FloatLabeledEditText with code (not with designer) and initialize
Dim txtEdit As FloatLabeledEditText
txtEdit.Initialize("txtEdit")
' Assign to b4xview with some properties
xV = txtEdit
xV.Color = xui.PaintOrColorToColor(Colors.Yellow)
' Add b4xview to hosting panel
p.AddView(xV, 0,0,0,0)
...
Custom views are designed to be added with the designer. It is however very simple to create a layout file with the custom view and load it multiple times. Tip: remove the call to AutoScaleAll from the designer script. Complete example: Sub Globals Private B4XSwitch1 As B4XSwitch End...
Some clarifications
I have created a library that contains some controls. The present control until recently had EditText as the word processing field in my control.
You design the control directly with code or by entering Custom to the designer.
I wanted to change EditText to one of the Floats ... in order to avoid adding an extra Label as a caption to the control.
Results
A. With FloatLabeledEditText it gives me an error for Initialize in the control
B. With B4XFloatTextField and BRB4XFloatTextField it gives me an error to Initialize in B4XView.
Some clarifications
I have created a library that contains some controls. The present control until recently had EditText as the word processing field in my control.
You design the control directly with code or by entering Custom to the designer.
I wanted to change EditText to one of the Floats ... in order to avoid adding an extra Label as a caption to the control.
Results
A. With FloatLabeledEditText it gives me an error for Initialize in the control
B. With B4XFloatTextField and BRB4XFloatTextField it gives me an error to Initialize in B4XView.
If you want to replace EditText with B4XFloatTextField , you can't just do it from code by simply replacing the declaration as you thought.
You have to replace each EditText on the design with B4XFloatTextField and then edit the code. Obviously by inserting from Design you don't have to initialize it. If you want to do everything from code you have to look at the link I indicated, but it is not easy.