9

I have recently face this problem and I want to share with you my solution.

Problem:

  • You have a ListView with a Edit Text for each row like this:

MainList.xml

<ListView
    android:id="@+id/listViewServ"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"/>

RowList.xml

<TextView 
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="100dp"
        android:layout_height="wrap_content"  
        android:inputType="number"/>
  • You are working with TABS: tabHost or TabActivity. (this is very important to notice).
  • When you click on any of the list item EditText, the focus moves out immediately and you are not able to type anything. However the keyboard is still on. But what ever you type in does not appear as the focus is lost.

Now, I'm going to give you my solution posting my own question.

kiduxa
  • 3,339
  • 11
  • 37
  • 52

1 Answers1

31

I have seen that some solutions are using:

android:descendantFocusability="beforeDescendants"

in the layout of the definition of the list.

For me this wasn't necessary. The problem was fixed using android:windowSoftInputMode="adjustPan":

<activity
        android:name="mainActivity"
        android:windowSoftInputMode="adjustPan"
        android:label="@string/app_name" >
    </activity>

in the Manifest.xml.

But you have to make sure that this line of code goes in the activity where you are defining the TabHost or TabActivity!!!.

kiduxa
  • 3,339
  • 11
  • 37
  • 52
  • 12
    If you have an `EditText` near the bottom of the screen, this will cause it to be obscured by the keyboard even when trying to enter text into it. – blahdiblah Oct 31 '13 at 23:27
  • This works for me, on android 4.2 with cyanogenmod ROM, where other solutions fail. ;) well done, dude! – Marino Mar 05 '14 at 15:54
  • this solution is not working for me...something more? – Fran_gg7 Sep 09 '15 at 06:57
  • I have the ListView in dialog, this is now working in this case.... Is there any solution ? – Jayesh Dec 29 '15 at 07:09