すでに同様の質問をたくさん読みましたが、問題を解決する解決策が見つからなかったため、これを重複としてマークしないでください.
を含む がありListFragment
、を介して入力されます。リストの各行には、次の 3 つの要素があります。FrameLayout
ListView
custom ArrayListAdapter
Checkbox
、EditText
およびImageButton
。
私の問題は、をタップしEditText
て変更するstring
とキーボードが表示されるのですが、フォーカスがすぐに消えて書き込みができないことです。
私はすでにファイルに追加していることに注意しActivity
てmanifest
ください
android:windowSoftInputMode="adjustResize"
でさえ
android:descendantFocusability="afterDescendants" android:descendantFocusability="beforeDescendants"
問題を解決しません。
ここに私のXMLコードがあります:
行項目.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>
この場合、フォーカス可能性がどのように機能するかを理解するためのリソースを提案していただければ幸いです。
ありがとうございました
アップデート
EditText
キーボードが表示されることで問題が発生することがわかりました。ビューのリサイクルがフォーカスを失った理由だと思います。