我如何prevent从弹出软键盘?

编程入门 行业动态 更新时间:2024-10-09 18:23:06
本文介绍了我如何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从弹出软键盘?

本文发布于:2023-06-05 22:04:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/529902.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹出   键盘   prevent

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!