如何让我的Andr​​oid应用程序编程显示键盘 [英] how can my android app programmatically display the keyboard

查看:98
本文介绍了如何让我的Andr​​oid应用程序编程显示键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以编程方式告诉机器人打开键盘时,被一个EditText获得的焦点?

Is there any way to programmatically tell android to open the keyboard when the focus is obtained by an EditText?

另外,有没有办法告诉它打开数字键盘?

Also is there any way to tell it to open the numeric keyboard?

谢谢 维克多

推荐答案

要的显示的键盘:

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(viewToEdit, 0);

要的隐藏的键盘:

if (getCurrentFocus() != null) {
    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getApplicationWindowToken(), 0);
}

这篇关于如何让我的Andr​​oid应用程序编程显示键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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