简体   繁体   中英

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM