How to get the keyboard to show a return key?

℡╲_俬逩灬. 提交于 2020-02-28 05:38:04

问题


I think I've tried every combination, but I can't get the alpha keyboard to show the return key. It's always a "Done" button, which is not useful. On a Nexus 7 (4.1), it's worse, and shows a stupid smiley button along with the Done button, which makes no sense for my application. It's fine to have a Done button as long as I have a return button. Here's one of many options I've tried:

<AutoCompleteTextView
    android:id="@+id/annotate_edit"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="15dp"
    android:layout_marginLeft="60dp"
    android:layout_marginRight="60dp"
    android:layout_marginTop="15dp"
    android:completionThreshold="1"
    android:inputType="textCapSentences|textImeMultiLine"
    android:imeOptions="actionDone"
    android:lines="1"
    android:maxLength="18"
    android:textSize="30px" />

I've tried with and without the imeOpitons line, and various inputType options including removing it. There are options to make it a search button (not helpful), but nothing listed to make it a return key. I've also tried with "lines=2", which did not fix it. Any other ideas?


回答1:


Right now you have set imeOptions="actionDone". You say you've tried removing it, but all that does it default it to actionDone again, per the docs.

Try setting imeOptions="actionNone" instead. That should give you no action and force a return key.

I don't know that that by itself will guarantee a working multiline AutoCompleteTextView, however. I have one in an app, and it shows a return key on all my devices. The difference is the behaviour of the return key.

For instance, on my GNex (4.1), when you press return it line feeds properly.

On my SGS2 (2.3), nothing happens when you press it. No multiline, no completion. Just a dead button.

It could be the difference in the default EditText style in different APIs, so you should also try setting inputType="textMultiLine". There may be a subtle difference between that and textImeMultiLine.



来源:https://stackoverflow.com/questions/12945767/how-to-get-the-keyboard-to-show-a-return-key

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