[英]imeOption="actionNext" not working in TextInputLayout
我正在使用材料設計中的浮動提示。 我想將焦點從一個EditText
轉移到下一個,所以我在所有 editText 中放置imeOptions="actionNext"
,在最后一個EditText
中放置了imeOptions="actionDone
。但是焦點沒有轉移到下一個EditText
。
下面是我的 xml 的片段。
<android.support.design.widget.TextInputLayout
android:id="@+id/streetWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextInputStyle">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Street/Locality *"
android:imeOptions="actionNext"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/flatWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_10sdp"
android:theme="@style/TextInputStyle">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Building Name / Flat Number*"
android:imeOptions="actionNext"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
您應該在EditText
部分添加android:imeOptions="actionNext"
。
<android.support.design.widget.TextInputLayout
android:id="@+id/streetWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextInputStyle">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:maxLines="1"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
將屬性android:inputType="text"
添加到您的EditText
。
試試這個:
<android.support.design.widget.TextInputLayout
android:id="@+id/streetWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Street/Locality *"
android:imeOptions="actionNext"
android:maxLines="1"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/flatWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_10sdp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Building Name / Flat Number*"
android:imeOptions="actionNext"
android:maxLines="1"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
您應該在 Tag 部分添加android:inputType="text"
如果你不添加 inputType imeOption 是行不通的
試試這個:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimens_16dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/et_impian"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/text_fill_your_dream_here"
android:imeOptions="actionNext"
android:inputType="text"
android:backgroundTint="@color/color_green_manulife"/>
</android.support.design.widget.TextInputLayout>
在我的例子中,我還必須添加android:nextFocusForward="@id/secondInput"
。 確保在TextInputEditText
而不是TextInputLayout
上添加 id。
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First input">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/firstInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="number"
android:nextFocusForward="@id/secondInput">
<requestFocus />
</com.google.android.material.textfield.TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Second input">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/secondInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.