2017-10-06 84 views
0

當創建包含兩個editText小部件的簡單recyclerView時,輸入數據時下一個焦點元素的方向與pic1類似---如何設置pic2上下一個焦點元素的方向? 歡呼recycle查看下一個焦點方向

pic1

pic2

我簡單的代碼

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:id="@+id/edit_text_left" 
     tools:hint="editTextLeft" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:layout_height="wrap_content" /> 

    <EditText   
     android:id="@+id/edit_text_right" 
     tools:hint="editTextRight" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

回答

1

嘗試這種使用android:imeOptions="actionNext"將焦點移動到下一個Editext

<EditText 
    android:id="@+id/edit_text_left" 
    tools:hint="editTextLeft" 
    android:layout_width="0dp" 
    android:layout_weight="1" 
    android:inputType="text" 
    android:imeOptions="actionNext" 
    android:layout_height="wrap_content" /> 

讓你拉yout like this

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:id="@+id/edit_text_left" 
     tools:hint="editTextLeft" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:inputType="text" 
     android:imeOptions="actionNext" 
     android:layout_height="wrap_content" /> 

    <EditText   
     android:id="@+id/edit_text_right" 
     tools:hint="editTextRight" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:inputType="text" 
     android:imeOptions="actionNext" 
     android:layout_height="wrap_content" /> 

</LinearLayout>