Cippo
Cippo

Reputation: 1011

How to focus away from an EditText?

In my application I need to make something happen when an EditText loses its focus. When editing an EditText I can't make it lose its focus. In windows phone there is the this.Focus(); method but here in android it doesn't seem to be the same. How can I do???

Upvotes: 1

Views: 349

Answers (1)

Arpit Garg
Arpit Garg

Reputation: 8546

To focus away from Edit Text one should use clearFocus();

Now comes if you do need to handle any particular event if the focus is changed then..

**use Focus Change listener on view.**


onFocusChange(View v, boolean hasFocus)
  //Called when the focus state of a view has changed.
if(!hasfocus)
{
//Your piece of code if the focus is lost on text view..
}

Upvotes: 1

Related Questions