Ho due frammenti contenenti un paio di caselle EditText. Sono entrambi disposti in modo simile, tuttavia è molto strano che 1 si inserisca tra i campi EditText, ma l'altro no.XML Android: spostamento tra i campi EditText
Questo è quello che sto avendo problemi con:
<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>
Quando ho scheda dalla prima casella EditText, la messa a fuoco scompare poi su una seconda scheda si muove attenzione al secondo campo. Lo stesso di nuovo se metto a fuoco tab, poi scheda di nuovo e appare sul pulsante sottostante.
Non c'è niente di speciale in the Fragment's onCreateView oltre a ottenere i puntatori ai campi EditText. Come ho detto, ho una seconda vista molto simile che funziona bene.
Quando ho scheda, ho notato ottengo questi avvertimenti mostrando in 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 [email protected]
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 [email protected]
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 [email protected]
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 }
EDIT -----------------
Ok, come suggerito nei commenti, ho aggiunto onFocusChanged listener a tutte le viste (passate attraverso tutte e aggiunte listener) e loggato cosa è la vista. Ogni volta che registro, ottengo il registro ma la cosa strana è che registro alla prima casella EditText e il log dice che la casella editText ha lo stato attivo, faccio nuovamente tab e focus è perso ma il log dice che la stessa casella EditText ha lo stato attivo! Scheda di nuovo e il secondo ottiene messa a fuoco e il registro dice l'id corretto, scheda nuovamente messa a fuoco persa, ma ancora una volta il registro dice che la seconda casella EditText ha lo stato attivo anche se non ha !!
Comportamento molto strano.
può 'android: focusableInTouchMode' essere il problema? –
Ho paura di no. EditText è comunque focalizzabile. – Darren
Potrebbe avere qualcosa a che fare con il modo in cui viene aggiunto il frammento? Inoltre, c'è forse un modo per scoprire che cosa sta diventando attivo quando scompare dalle caselle di ExitText? – Darren