t0m
t0m

Reputation: 3104

EditText multiline with "next view button" instead of "new line button"

Goal is to use multiline EditText with android:inputType="textMultiLine" and with "next view button" such as android:inputType="text" (see picture 2).

<EditText
    android:id="@+id/addAffirmationContent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textMultiLine"
    android:maxLength="255"
    android:imeOptions="flagNoExtractUi" />

I tried many combinations with: android:inputType, singleLine, nextFocusDown, nextFocusUp, nextFocusLeft, nextFocusRight, nextFocusForward, imeOptions, lines, but android:inputType="textMultiLine" always forces new line button.

Tested on Nexus 5 Android 7.

Picture 1.: new line button:
new line button

Picture 2.: next view button:
next view button

Upvotes: 2

Views: 2929

Answers (2)

MikeL
MikeL

Reputation: 2894

I think what you are looking for is the same as in this answer:

In code:

editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);

and in xml:

android:inputType="textMultiLine"

Upvotes: 9

Rainmaker
Rainmaker

Reputation: 11090

These three lines in combination should replace your "enter" with "next"

<EditText 
    android:inputType="text"
    android:maxLines="1"
    android:imeOptions="actionNext" />

Android have a lot of"android:imeOptions" to specify the keyboard action button

android:imeOptions="actionGo"
android:imeOptions="actionDone"
android:imeOptions="actionNext"
android:imeOptions="actionPrevious"
android:imeOptions="actionSend"

and there are even more

Upvotes: 0

Related Questions