3

我需要为我的edittext设置actiondone而不设置singleLine oprions(我需要多行输入)。我该怎么做?

那是代码:

<EditText
    android:id="@+edit_text/title"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="Titolo"
    android:imeOptions="actionNext"
    android:singleLine="true" />

<EditText
    android:id="@+edit_text/content"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:gravity="top"
    android:hint="Inserisci la nota"
    android:singleLine="false"
    android:imeOptions="actionDone" />
4

3 回答 3

0

这对我有用:

    <EditText
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:imeOptions="actionDone"
        android:singleLine="false" />
于 2013-03-07T20:58:46.377 回答
0

由于 SingleLine = false/true 已被弃用。应用下面的代码。它对我有用。

 <EditText
    android:id="@+id/my_EditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:maxLines="1" 
    android:imeOptions="actionDone"/>
于 2019-04-01T12:33:16.820 回答
0

我找到了一个解决方案 Set on your view 以编程方式

mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT);
mEditText.setImeActionLabel(getResources().getString(R.string.done), EditorInfo.IME_ACTION_DONE);
mEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);

xml 文件将是:

<EditText
    android:id="@+id/my_EditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

解决方案在这里找到: https ://gist.github.com/Dogesmith/2b98df97b4fca849ff94

于 2019-04-01T10:51:10.460 回答