I already read tons of similar questions, but I found no solution that fixed my problem, so please do not mark this as duplicate.
I have a ListFragment with a FrameLayout containing a ListView, populated through a custom ArrayListAdapter. Each row of the list has three elements:
Checkbox, EditText and ImageButton.
My problem is that when I tap on an EditText to change the string it contains the keyboard shows up, but the focus immediately goes away and I'm not able to write.
Please note that I already have added to my Activity in the manifest file
android:windowSoftInputMode="adjustResize"
even the
android:descendantFocusability="afterDescendants" android:descendantFocusability="beforeDescendants"
doesn't solve the problem.
Here is my XML code:
row_item.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" > <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/item_checkbox" android:layout_alignParentLeft="true" android:layout_centerVertical="true" /> <EditText android:id="@+id/item_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="60px" android:text="Test text" android:singleLine="true" android:layout_toRightOf="@id/item_checkbox" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/item_important" android:layout_toStartOf="@+id/item_important" /> <ImageButton android:id="@+id/item_important" android:layout_width="20dip" android:layout_height="20dip" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="10dp" android:visibility="visible" android:layout_marginLeft="10dp" /> </RelativeLayout> fragment_list.xml
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="8dp" android:paddingRight="8dp" > <ListView android:id="@id/android:list" android:layout_width="match_parent" android:layout_height="match_parent" /> </FrameLayout> It would be great if you could suggest me some resource where to understand how focusability works in this case.
Thank you
UPDATE
I found out the problem is created by the keyboard showing up: I guess the view recycling is the reason why the EditText loses focus.