隐藏软键盘上的活动,没有任何键盘操作 [英] Hide soft keyboard on activity without any keyboard operations

查看:139
本文介绍了隐藏软键盘上的活动,没有任何键盘操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有每片一个活动标签视图,当我从第一个选项卡,其中有一个TextView切换到第二个选项卡,这只能说明一个可点击列表,软键盘仍然存在。我希望它去了,所以我想这样的:

I have a tabbed view with one Activity per tab, and when I switch from the first tab, which has a TextView, to the second tab, which only shows a clickable list, the soft keyboard is still there. I want it to go away, so I tried this:

public static void hideSoftKeyboard (Activity activity, View view) {
  InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

但这不起作用,因为没有相关的观点提供,因为是采用键盘输入,屏幕上没有显示。关于如何解决这个任何建议?

but this does not work, because there is no relevant view to provide, as there is no View on the screen that takes keyboard input. Any suggestions on how to solve this?

推荐答案

在你的code第3行试试这个:

Try this in 3rd line of your code:

imm.hideSoftInputFromWindow(view.getApplicationWindowToken(),0)

这篇关于隐藏软键盘上的活动,没有任何键盘操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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