如何阻止虚拟键盘,同时点击的EditText android系统中? [英] how to block virtual keyboard while clicking on edittext in android?

查看:134
本文介绍了如何阻止虚拟键盘,同时点击的EditText android系统中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何阻止虚拟键盘同时点击EditText上的机器人

How to block virtual keyboard while clicking on edittext in android

推荐答案

<一个href="http://groups.google.com/group/android-developers/browse%5Fthread/thread/180530f680374493?pli=1">Here是一个网站,会给你你所需要的。

Here is a website that will give you what you need.

作为一个总结,它提供的链接 InputMethodManager 查看从Android开发人员。这将参照 getWindowToken 里面的查看 hideSoftInputFromWindow() InputMethodManager

As a summary, it provides links to InputMethodManager and View from Android Developers. It will reference to the getWindowToken inside of View and hideSoftInputFromWindow() for InputMethodManager

有一个更好的答案中给出的链接,希望这有助于。

A better answer is given in the link, hope this helps.

从上面贴的链接,下面是一个例子消耗onTouch事件:

From the link posted above, here is an example to consume the onTouch event:

editText_input_field.setOnTouchListener(otl);

private OnTouchListener otl = new OnTouchListener() {
    public boolean onTouch (View v, MotionEvent event) {
            return true; // the listener has consumed the event
    }
 };

下面是从同一网站的另一个例子。这要求工作,但似乎是因为一个坏主意,你的编辑框 NULL 将不再编辑:

Here is another example from the same website. This claims to work but seems like a bad idea since your EditBox is NULL it will be no longer an editor:

MyEditor.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
    int inType = MyEditor.getInputType(); // backup the input type
    MyEditor.setInputType(InputType.TYPE_NULL); // disable soft input
    MyEditor.onTouchEvent(event); // call native handler
    MyEditor.setInputType(inType); // restore input type
    return true; // consume touch even
}
});

希望这点你在正确的方向。

Hope this points you in the right direction

这篇关于如何阻止虚拟键盘,同时点击的EditText android系统中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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