いくつかの EditText ボックスがオンになっている 2 つのフラグメントがあります。どちらも同様にレイアウトされていますが、1 つは EditText フィールド間でタブ移動するのに、もう 1 つは移動しないのは非常に奇妙です。
これは私が問題を抱えているものです:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loginparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff008DFF" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dip"
android:background="#ff008DFF"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dip"
android:contentDescription="@string/logoDesc"
android:src="@drawable/logo1" />
<EditText
android:id="@+id/usernameLog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/username"
android:imeOptions="actionNext"
android:singleLine="true"
android:textSize="14sp" />
<EditText
android:id="@+id/passwordLog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:singleLine="true"
android:textSize="14sp" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="@string/newuser"
android:textColor="#ffffffff"
android:textSize="14sp" />
<Button
android:id="@+id/viewSignupBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/signup" />
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBarLog"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:padding="70dip"
android:visibility="gone" />
</RelativeLayout>
最初の EditText ボックスからタブで移動すると、フォーカスが消え、2 番目のタブでフォーカスが 2 番目のフィールドに移動します。タブフォーカスが移動した場合も同じで、もう一度タブを押すと、その下のボタンに表示されます。
EditText フィールドへのポインターを取得することを除けば、フラグメントの onCreateView では特別なことは何も行われていません。私が言うように、私はうまく機能する非常によく似た2番目のビューを持っています。
タブに移動すると、Logcat に次の警告が表示されることに気付きました。
04-24 19:31:29.695: D/InputEventConsistencyVerifier(2040): KeyEvent: ACTION_UP but key was not down.
04-24 19:31:29.695: D/InputEventConsistencyVerifier(2040): in android.support.v4.app.NoSaveStateFrameLayout@40f365b8
04-24 19:31:29.695: D/InputEventConsistencyVerifier(2040): 0: sent at 4325570000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=4325570, downTime=4325514, deviceId=0, source=0x101 }
04-24 19:31:31.076: D/InputEventConsistencyVerifier(2040): KeyEvent: ACTION_UP but key was not down.
04-24 19:31:31.076: D/InputEventConsistencyVerifier(2040): in android.widget.EditText@40f78e98
04-24 19:31:31.076: D/InputEventConsistencyVerifier(2040): 0: sent at 4326945000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=4326945, downTime=4326889, deviceId=0, source=0x101 }
04-24 19:31:32.255: D/InputEventConsistencyVerifier(2040): KeyEvent: ACTION_UP but key was not down.
04-24 19:31:32.255: D/InputEventConsistencyVerifier(2040): in android.widget.EditText@40f73678
04-24 19:31:32.255: D/InputEventConsistencyVerifier(2040): 0: sent at 4328123000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=4328123, downTime=4328053, deviceId=0, source=0x101 }
編集 - - - - - - - - -
コメントで示唆されているように、onFocusChanged リスナーをすべてのビューに追加し (すべてをループしてリスナーを追加)、ビューが何であるかをログに記録しました。タブするたびにログが表示されますが、奇妙なことに、最初の EditText ボックスにタブで移動すると、ログには editText ボックスにフォーカスがあると表示され、もう一度タブに移動するとフォーカスが失われますが、ログには同じ EditText ボックスにフォーカスがあると表示されます! もう一度タブを押すと、2 番目にフォーカスがあり、ログに正しい ID が表示されます。タブは再びフォーカスが失われますが、ログには 2 番目の EditText ボックスにフォーカスがないにもかかわらず、フォーカスがあると表示されます!!
非常に奇妙な振る舞い。