I've looked everywhere, on the site and on Web, but I can not find a way to get the LostFocus (HasFocus = False) when the view that gets the focus has not an editable text, such as buttons, imageviews, ...
The feature that I would get is simple, in theory .
Let's say I have a EditText; the user enters text and then press the OK button.
It is obvious that I could check the contents entered in the EditText inside the btnOK_Click event, but it is just an example to say that when the user presses OK, the event EditText_FocusChanged does not fire.
Private Sub TextBox1_LostFocus(sender As Object, e As System.EventArgs) Handles TextBox1.LostFocus
If TextBox1.Text.Length = 0 Then
MessageBox.Show("Invalid value")
TextBox1.Focus()
End If
End Sub
As thedesolatesoul said, pressing the OK button in an edittext doesn't necessarily move the focus, unless there is another focusable view for it to go to and you haven't set force done on the keyboard.
From? So I need to call xxx_request_focus inside the button_click event (and in all views for each EditText).
In this case, you might as well write:
EditText1_FocusChanged (True)
In VB.Net, buttons receive focus, same as other not editable controls
1) the button is in the focused state, it can have a different graphic (Which may be the same as pressed by default because buttons are not normally focusable) but you can change it using a statelistdrawable if you really want to.