actionNext & textMultiline not working

1.5k Views Asked by At

I want a Multiline EditText to allow imeOptions="actionNext".


This works, but only allows single line input

<EditText>
    ...
    android:inputType="textCapSentences|textAutoCorrect"
    android:imeOptions="actionNext"
    ...
</EditText>

This changes the imeOption to an enter key.

<EditText>
    ...
    android:inputType="textCapSentences|textAutoCorrect|textMultiline"
    android:imeOptions="actionNext" <!-- Why is this code skipped? -->
    ...
</EditText>

The Google Keep and Gmail apps do this somehow, so don't tell me it isn't possible.

1

There are 1 best solutions below

0
On

The enter key can only do one thing: enter new line to the editor or move cursor to the next field. One way to implement this is have the enter key move to the next field but still allow text in the editor to auto-wrap.

In XML:

<EditText
    android:singleLine="true"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="@string/default_label_a"
    android:selectAllOnFocus="true"
    android:maxLines="5"
    android:imeOptions="actionNext"
/>

In code:

edittext.setHorizontallyScrolling(false);
edittext.setMaxLines(Integer.MAX_VALUE);