9

I would like to have a custom ListView, where each row contains an EditText field, that may be edited by the user. But when I click on one of the EditTexts I lose the focus, and can't type text there (I suppose because the other rows are redrawn and get the focus). What can I do?

dldnh
  • 8,923
  • 3
  • 40
  • 52

2 Answers2

23

If the problem is related to software keyboard, try to set windowSoftInputMode to adjustPan in activity declaration in AndroidManifest.xml as follows:

  ...
    <activity 
        android:name=".activity.Activity"
        android:label="@string/activity"
        android:windowSoftInputMode="adjustPan" />
    ...

It should help. Check http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html for more info about it.

Ondra Zahradnik
  • 683
  • 6
  • 10
  • Worked for me. I have several widgets in each line, and some of them are EditText. With your solution I don't lose focus when editing. – ffleandro Feb 02 '12 at 17:36
2

You must set the focusable of the edittext (EditText.setFocusable(true))

Nicolas
  • 21
  • 1