我如何prevent从弹出软键盘? [英] How do I prevent the software keyboard from popping up?

查看:101
本文介绍了我如何prevent从弹出软键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我自己的键盘在我的应用程序,所以我想隐藏软件键盘所有的时间(具体活动和放大器;对话框)。 我尝试了两种选择:

I have my own keypad in my application so I want to hide the software keyboard all the time(in specific activities & dialogs). I experimented with two options:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

这code prevent从弹出的开头,但是当我点击文本框的键盘仍然弹出键盘。

This code prevent the keyboard from popping up at the beginning, but when I click on the textbox the keyboard still pops.

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

这code隐藏键盘,但它并没有prevent键盘的弹出。

This code hide the keyboard, but it doesn't prevent the keyboard from popping up.

请帮助!

推荐答案

终于想通了!

我用

public void supressKeyboard() {
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
}

有关,我想晚饭preSS键盘活动(你可以把它放在那里的所有其他活动,从继承一般的活动)

for the activities where I want to suppress the keyboard(you can put it in a general activity where all other activities inherit from)

但这并不prevent从弹出当你点击的EditText文本框的键盘。我所做的是我所消耗的onTouch事件的文本框中:

But this won't prevent the keyboard from popping up when you click on the EditText textbox. What I did is I consumed the onTouch event for the text box:

@Override
public boolean onTouchEvent(MotionEvent event) {
    return true;
}

这篇关于我如何prevent从弹出软键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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