1

Can anyone help me, Im beginner in android development, EditText is always focused, and i want to remove focus when clicking any other object, for example, ListView, Button... i want EditText to focus only when user clicks onto it

Kaushik
  • 6,077
  • 5
  • 35
  • 53
Giorgi
  • 13
  • 3

3 Answers3

1

No object is focused by default so check your XML layout file and ensure you do not have <requestFocus /> set on EditText in subject. If so, remove it from XML file - you may also want to check for requestFocus() calls, just in case.

Marcin Orlowski
  • 68,918
  • 10
  • 117
  • 136
0

You can try using clearFocus() method on EditText..

EditText txt;
txt=(EditText) findViewById(R.id.somename);

txt.clearFocus();

Or you can use

 private void hideDefaultKeyboard() {
       activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);//u     have got lot of methods here
}
inquisitive
  • 3,558
  • 6
  • 26
  • 54
0

make sure there is no request focus in your layout and adding this might help

android:focusable="false" android:clickable="false"

vera
  • 3
  • 3