没有singleLine选项的EditText的actionDone

问题描述 投票:2回答:3

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

那是代码:

<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" />
android android-edittext android-softkeyboard
3个回答
0
投票

这对我有用:

    <EditText
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:imeOptions="actionDone"
        android:singleLine="false" />

0
投票

我已经以编程方式在您的视图上找到了解决方案

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


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"/>
© www.soinside.com 2019 - 2024. All rights reserved.