Done key not showing up on keyboard

与世无争的帅哥 提交于 2019-12-25 06:01:41

问题


I am making an Android app and want the done key to show up on the keyboard when the user is typing into the keyboard. This is the XML code for the EditText:

    <EditText
    android:id="@+id/answer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:gravity="center_horizontal"
    android:textColor="#ffffff"
    android:layout_marginBottom="113dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:imeOptions="actionDone"
    />

I thought that adding the android:imeOptions="actionsDone would have the done button appear, but instead the enter button is there and when it is pressed, a new line is created in the EditText. What is the issue?


回答1:


You will not get done by adding imeOptions. Add the below attribute to your EditText:

android:singleLine="true"

This will make your EditText a single line and you will see the Done button if that is the only EditText or last EditText. If there are multiple EditText items, then you will see Next button.



来源:https://stackoverflow.com/questions/30697547/done-key-not-showing-up-on-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!