Reputation: 7048
How to check an EditText has focus? is there any method boolean hasFocus()
Upvotes: 6
Views: 10798
Reputation: 1821
Yes, hasFocus()
is there, inherited from android.view.View
Another way to achieve this
EditText et = (EditText) findViewById(R.id.edittxt);
if(this.getCurrentFocus().getId() == et.getId()){
// your view is in focus
}else{
// not in the focus
}
Upvotes: 12