How to use more then one imeOptions in android

3.4k views Asked by At

Is it possible to use more then 1 imeOptions in Android xml ? for the same text field.

e.g.

<EditText
    android:id="@+id/mywriting"
    android:imeOptions="actionDone"
    android:imeOptions="autoText"/>

Right now it is giving me an error, saying 1 imeOptions has already been used and I can't use any more

3

There are 3 answers

3
shkschneider On
<EditText
android:id="@+id/mywriting"
android:imeOptions="actionDone|autoText" />

ERRATUM

My bad. It is the inputType not the imeOptions that can be combined.

<EditText
android:id="@+id/mywriting"
android:inputType="..."
android:imeOptions="actionDone" />
0
TwiXter On

Hey guys i've seen your post while checking for an issue, which is the following:

When applying 2 IME options within the XML it works:

tools:imeOptions="actionDone|actionPrevious"
//Even tools:imeOptions="actionPrevious|actionNext" will work

When doing so: by default, the Ime shown will be the "DONE" (OR "NEXT" when using previous/next), but if you remain pressed some seconds on it, the "PREVIOUS" button is shown and then if you release the "DONE" button it will perform the "PREVIOUS" IME action... Whatever the options order.

Dual IME options demo

Smartest thing is that... if you do the same by code:

myEditText.setImeOptions(EditorInfo.IME_ACTION_DONE|EditorInfo.IME_ACTION_PREVIOUS);

Then it doesn't work: you get only the "PREVIOUS" button

EDIT OK this was a bad practice: if you wish to use Previous/Next, better is to remove ImeOptions and replace by :

        android:nextFocusUp="@id/layoutItemId" //Previous view to focus
        android:nextFocusDown="@id/layoutBBDate" //next view to focus

If you wish to use "Previous/Done" declare:

            android:nextFocusUp="@id/layoutItemId" //Previous view to focus
            tools:imeOptions="actionDone"
0
GMax On

Use | to combine, like that:

android:imeOptions="actionDone|actionNext"

In your case, the problem is with autoText, which is not a valid value for imeOptions.