Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting EditText imeOptions to actionNext has no effect

I have a fairly complex (not really) xml layout file. One of the views is a LinearLayout (v1) with two children: an EditText(v2) and another LinearLayout(v3). The child LinearLayout in turn has an EditText(v4) and an ImageView(v5).

For EditText v2 I have imeOptions as

android:imeOptions="actionNext" 

But when I run the app, the keyboard's return does not check to next and I want it to change to next. How do I fix this problem?

Also, when user clicks next, I want focus to go to EditText v4. I do I do this?

For those who really need to see some code:

<LinearLayout         android:id="@+id/do_txt_view"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="@color/col6"         android:orientation="vertical"         android:visibility="gone" >          <EditText             android:id="@+id/gm_title"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_margin="5dp"             android:background="@drawable/coldo_text"             android:hint="@string/enter_title"             android:maxLines="1"             android:imeOptions="actionNext"             android:padding="5dp"             android:textColor="pigc7"             android:textSize="ads2" />          <LinearLayout             android:layout_width="match_parent"             android:layout_height="100dp"             android:orientation="horizontal" >              <EditText                 android:id="@+id/rev_text"                 android:layout_width="0dp"                 android:layout_height="match_parent"                 android:layout_gravity="center_vertical"                 android:layout_margin="5dp"                 android:layout_weight="1"                 android:background="@drawable/coldo_text"                 android:hint="@string/enter_msg"                 android:maxLines="2"                 android:padding="5dp"                 android:textColor="pigc7"                 android:textSize="ads2" />              <ImageView                 android:layout_width="wrap_content"                 android:layout_height="match_parent"                 android:layout_gravity="center_vertical"                 android:background="@drawable/colbtn_r”                 android:clickable="true"                 android:onClick=“clickAct”                 android:paddingLeft="5dp"                 android:paddingRight="5dp"                 android:src="@drawable/abcat” />         </LinearLayout>     </LinearLayout> 
like image 517
Katedral Pillon Avatar asked Apr 12 '14 22:04

Katedral Pillon


People also ask

Which method is used to set the EditText?

In android, we can set the text of EditText control either while declaring it in Layout file or by using setText() method in Activity file.

What is the function of setting autoText attribute in EditText?

android:autoText If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors.

What is imeOptions?

android:imeOptions="actionSend" /> You can then listen for presses on the action button by defining a TextView.OnEditorActionListener for the EditText element. In your listener, respond to the appropriate IME action ID defined in the EditorInfo class, such as IME_ACTION_SEND . For example: Kotlin Java.

How can add only numbers in EditText in android?

You can use android:inputType="number" in the XML file. You can specify other values such as numberDecimal as well. Also, you might additionally want to use android:singleLine="true" for a single line Edittext .


1 Answers

Just add android:maxLines="1" & android:inputType="text" to your EditText. It will work!! :)

like image 179
Surendra Kumar Avatar answered Oct 12 '22 16:10

Surendra Kumar