Yossi
Yossi

Reputation:

Android: EditText in ListView

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?

Upvotes: 9

Views: 10971

Answers (2)

Nicolas
Nicolas

Reputation: 21

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

Upvotes: 2

Ondra Zahradnik
Ondra Zahradnik

Reputation: 683

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.

Upvotes: 23

Related Questions