我想自动显示软键盘时的EditText
聚焦(如果设备没有物理键盘),我有两个问题:
I want to automatically show the soft-keyboard when an EditText
is focused (if the device does not have a physical keyboard) and I have two problems:
在显示我的 When my 当我点击键盘上完成,键盘dissmissed但 And when I click done on the keyboard, the keyboard is dissmissed but the 要继续,我的问题是有东西更像是在iPhone上:它让我的 To resume, my problem is to have something more like on the iPhone: which keep the keyboard sync with my 要强制软键盘出现,你可以使用 To force the soft keyboard to appear, you can use 和有关 And for removing the focus on 我希望这有助于 要关闭它,你可以使用的活动,我的
显示我的的EditText
专注但不显示的键盘,我需要再次点击它以显示键盘(的活动时,应显示)。
Activity
is displayed, my EditText
is focused but the keyboard is not displayed, I need to click again on it to show the keyboard (it should be displayed when my Activity
is displayed).
的EditText
保持专注和y不想(因为我的编辑完成) EditText
stays focused and y don't want (because my edit is done).的EditText
国家(重点/非重点)键盘同步,当然不不present软键盘,如果有一个物理之一。EditText
state (focused / not focused) and of course does not present a soft-keyboard if there is a physical one.推荐答案
EditText yourEditText= (EditText) findViewById(R.id.yourEditText);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);
的EditText
删除焦点,saddly你需要有一个虚拟的查看
抓住重点。EditText
, saddly you need to have a dummy View
to grab focus.InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);