安卓:如何关闭IME的一个EditText? [英] Android: How to turn off IME for an EditText?

查看:125
本文介绍了安卓:如何关闭IME的一个EditText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何关闭的输入法的功能的EditText

How do I turn off the IME-functionality of an EditText?

?或:我如何避免输入法键盘的显示

Or: How do I avoid the display of the IME-keyboard?

我有一个布局在我的专用键盘位于下方的的EditText ,所以没有需要显示的IME。请理解,我无法实现我的键盘作为输入法,因为它是专用于这个非常的EditText ,并用它在任何其他情况下只会导致问题。

I have a layout where my special keyboard sits below the EditText so there's no need to show the IME. Please understand that I cannot implement my keyboard as IME as it is specific for this very EditText and using it in any other context would only cause problems.

我试图用

getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

的onCreate()活动的,但似乎并没有做在这种情况下任何东西。

in the onCreate() of the activity, but that doesn't seem to do anything in this situation.

推荐答案

想我找到了一种方法来做到这一点...子的EditText 并重写<一个href=\"http://developer.android.com/reference/android/widget/TextView.html#onCheckIsTextEditor%28%29\"><$c$c>onCheckIsTextEditor()返回false:

Think I found a way to do it... subclass EditText and override onCheckIsTextEditor() to return false:

public class EditTextEx extends EditText {

    public EditTextEx(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override 
    public boolean onCheckIsTextEditor() {
        return false;
    }       
}

我测试过它,我不能让软键盘显示在所有。

I've tested it and I can't get the soft keyboard to show at all.

这篇关于安卓:如何关闭IME的一个EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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