Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

actionNext & textMultiline not working

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.

like image 422
Michael Avatar asked May 03 '26 15:05

Michael


1 Answers

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);
like image 145
minun09 Avatar answered May 05 '26 05:05

minun09



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!