Android Question How to force an EditText to loose the focus ?

marcick

Well-Known Member
Licensed User
Longtime User
Yes, I already tried that trick, but if the control is invisible it does not accept the focus.
Also if I set it visible and move it off-screen, let's say .left=10000 it does not accept focus.
(ciao Luca, non snobbo nessuno ma qua siamo in tanti !)
 
Upvote 0

fixit30

Active Member
Licensed User
Longtime User
Yes, I already tried that trick, but if the control is invisible it does not accept the focus.
Also if I set it visible and move it off-screen, let's say .left=10000 it does not accept focus.

It does look like if the EditText is not Visible then it will not accept focus, however with my Sample attached it DOES work if the EditText is off the screen. If you look at the Layout file in the designer and set zoom to 50% you will see the second EditText.
 

Attachments

  • Sample.zip
    12 KB · Views: 392
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I have used this workaround a few times .. and agree with @fixit30 that it works if the ET is off screen.
In the Designer EditText is set to ..
B4X:
Visible = True
Enabled = False

and hidden beneath another view (Send to Back in the Designer)
When needed I call
B4X:
  edtTakeFocus.RequestFocus
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Hi all,
I don't know why fixit30 sample was working and the same trick on my project not. I have removed my EdtTexts and added again, now it behaves as desired.
Thanks everybody
Marco
 
Upvote 0
Top