Activity.Addview Issue

bishmedia

Member
Licensed User
Longtime User
Im adding a text box with code rather than 'Designer' but when i click on it its not calling the 'FocusChanged' event??

Can anyone tell me where i have gone wrong??

B4X:
Sub Globals
   Dim txtContactName As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
   txtContactName.Initialize("")
   txtContactName.Color = Colors.White
   txtContactName.TextSize = 20
   txtContactName.TextColor = Colors.Black
   txtContactName.Gravity = Gravity.LEFT + Gravity.CENTER_VERTICAL
   txtContactName.Text = ""
   Activity.AddView(txtContactName, 5%x, 20%y, 85%x, 5%y)
End Sub

Sub txtContactName_FocusChanged (HasFocus As Boolean)
  Dim Send As EditText
  Send=Sender
  If HasFocus=True Then
    Send.Color=Colors.Cyan
   Send.TextColor=Colors.Black
  Else
     Send.Color=Colors.White
  End If
End Sub
 

bishmedia

Member
Licensed User
Longtime User
Thankyou all, i tried for ages looking for some other posts or tutorials for this :)

Thank god it was a simple fix :)
 
Upvote 0
Top