2012-03-13 86 views
12

我有一個由垂直方向包含多個EditText的LinearLayout組成的佈局。每個EditTexts的虛擬鍵盤都有一個「下一個」按鈕。按下「下一步」按鈕將光標移動到它下面的EditText。EditText選項卡順序

然而,在這些EditTexts中間的某個我添加了另一個LinearLayout中,這一個水平的,它裏面的幾個EditTexts。這給我留下了幾個垂直堆疊的EditText,然後是一排水平的EditTexts,然後更多的EditTexts垂直堆疊在下面。

的tab順序開始和以前一樣,但是當它到達水平的LinearLayout的第一EditText上,擊中「下一步」按鈕不會移動到下一個的EditText其右側。它將兩個向右跳到下面的EditText。

我該如何實現我想要的Tab鍵順序?

I've attached an image, a true work of art really, of the order I want

回答

36

使用android:nextFocusDown =「您的下一個id編輯文本」。例如:

.... 
    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 
    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="200dp" 
     android:layout_height="wrap_content" 
     android:nextFocusDown="@+id/editText2" /> 
    <EditText 
     android:id="@+id/editText2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 
    </LinearLayout> 
    ....