Porting a program from B4a to B4j
One part of program can have changing number of textfield boxes. I use FocusChanged() to identify which textbox is active and in some cases use a spinner to allow user to only choose from a known list
I have defined a Process Variable
Initialize it
Use the following to select the spinner
Which works fine and then this to attach the spinner value to the editTxtfocus.text
This does not work the error is :
java.lang.RuntimeException: Object should first be initialized (TextField).
Can someone please explain why it is not working. The B4a version works fine
One part of program can have changing number of textfield boxes. I use FocusChanged() to identify which textbox is active and in some cases use a spinner to allow user to only choose from a known list
I have defined a Process Variable
B4X:
Private EditTxtFocus As TextField
Initialize it
B4X:
EditTxtFocus.Initialize("editFocus")
Use the following to select the spinner
B4X:
' Selects the edit textfield touched
Sub edtEdit_FocusChanged (HasFocus As Boolean)
If HasFocus Then
EditTxtFocus = Sender
spEquipment.Visible=False
If DBName = "RAWTERMS" Then
If EditTxtFocus.Tag = 0 Or EditTxtFocus.Tag = 4 Then ' tags assigned numerically as edtEdit textfields created on pane
spEquipment.Left = edtEdit(EditTxtFocus.Tag).Left ' places spinner near edtEdit textfield
spEquipment.Top = edtEdit(EditTxtFocus.Tag).Top
spEquipment.Visible = True
End If
Else
EditTxtFocus.Enabled=True
EditTxtFocus=Null
End If
End Sub
Which works fine and then this to attach the spinner value to the editTxtfocus.text
B4X:
Sub spEquipment_ValueChanged (Value As Object)
Log(spEquipment.Value)
EditTxtFocus.Text=spEquipment.Value
End Sub
This does not work the error is :
java.lang.RuntimeException: Object should first be initialized (TextField).
Can someone please explain why it is not working. The B4a version works fine