2011-05-06 68 views
7

我試圖在自定義手動編碼的文本字段上顯示軟鍵盤。我使用下面的代碼,並在右下角得到帶有返回字符的標準鍵盤。使用OK/DONE按鈕在Android上以編程方式顯示鍵盤

inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); 

我想顯示右下方有OK(或可能已完成)的鍵盤。當我做了一些研究時,我發現inputType可以在EditText(我沒有在這種情況下使用)上設置,但不是用於我使用的視圖(GLSurfaceView)。

任何想法,我可以得到另一種鍵盤顯示?

編輯我試過這裏發佈的解決方案: - Multiline EditText with Done SoftInput Action Label on 2.3但不幸的是它沒有顯示DONE按鈕(我在Android 2.1上)。我嘗試更改inputType字段,並且確實更改了類型(我試過「電話」),但沒有完成按鈕。

感謝您的幫助。

回答

13

如果你想獲得軟鍵盤上的完成按鈕,您應該設置的EditText字段的「輸入法選項」,以actionDone

<EditText android:text="EditText" android:layout_width="fill_parent" 
android:id="@+id/editText1" android:layout_height="wrap_content" 
android:imeOptions="actionDone"/> 
+0

感謝woodshy,但我不會在這種情況下使用的EditText,我在OpenGL中直接渲染文本 – 2011-06-06 12:41:21

+0

Ime Option在mycase中不起作用。使用4.2 – 2014-09-21 12:12:53

+1

嘗試添加'android:singleLine =「true」' – Marina 2014-12-17 20:53:31

相關問題