软键盘......没有涉及到的EditText? [英] Soft keyboard ... not related to EditText?

查看:177
本文介绍了软键盘......没有涉及到的EditText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果硬键盘可用,它产生由安其的onkeydown,的onkeyup等。

If hard keyboard is available, it generates key events processed by onKey onKeyDown, onKeyUp, etc.

如果硬键盘无法使用,看来自然表现出软键盘在期望它会产生相同的密钥的事件。

If hard keyboard is unavailable, it appears natural to show soft keyboard in expectation it will generate same key events.

是否可以显示通过的EditText比其他键盘?

Is it possible to show a keyboard other than via EditText?

我能想出是指的EditText code :)有人唯一的想法可能已经这样做了。

The only idea I can come up with is referring to EditText code :) Someone may already have done that.

一个proposito 的,Android的终端仿真器正是这么做的:它允许进入从软键盘的键不使用的EditText,因此这个想法并非没有意义。

A proposito, Android Terminal Emulator does exactly that: it allows entering keys from soft keyboard without using EditText, therefore the idea is not pointless.

推荐答案

根据我的研究,并从的这个文章,似乎可以显示/比较容易隐藏软键盘,但它是不推荐的。

Based on my research and from this article, it seems you can show/hide the soft keyboard rather easily but it's not recommended.

从该网站上,code是如下:

From that website, the code is as follows.

显示键盘......也许的onClick或onOptionsItemSelected:

Showing the keyboard...perhaps onClick or onOptionsItemSelected:

EditText txtName = (EditText) findViewById(R.id.txtName);
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
inputMethodManager.showSoftInput(txtName, InputMethodManager.SHOW_IMPLICIT);

隐藏键盘:

InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

现在再次,是不是在指导方针建议使用此方法,但如果你想尝试一下,这将是一段路要走。

Now again, this method is not recommended in the guidelines but if you would like to try it, this would be the way to go.

祝你好运!

这篇关于软键盘......没有涉及到的EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆