【问题标题】:Disabling the soft keyboard [duplicate]禁用软键盘[重复]
【发布时间】:2017-11-24 11:19:00
【问题描述】:

我需要禁用软键盘,只启用硬键盘,所以我创建了这种edittext,效果很好,但是在某些htc手机上这种类型的edittext禁用多行语句(不知道它是如何工作的) .

public class NoImeEditText extends EditText {
    public NoImeEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    @Override
    public boolean onCheckIsTextEditor() {
        return false;
    }
}

我使用这种代码的另一种方式,它不起作用。

    keyboardText.setShowSoftInputOnFocus(false);


    InputMethodManager imm = (InputMethodManager)getMainActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null)
        imm.hideSoftInputFromWindow(keyboardText.getWindowToken(), 0); 

【问题讨论】:

    标签: android android-edittext android-keypad


    【解决方案1】:

    这可能有效,

       @Override
        protected void onCreate(Bundle savedInstanceState) {
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    }
    

    这将隐藏软键盘。

    【讨论】:

      猜你喜欢
      • 2017-08-15
      • 2017-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多