无法隐藏搜索查看iconfiedbydefault的虚拟键盘(假) [英] Unable to hide the virtual keyboard of SearchView iconfiedbydefault(false)

查看:189
本文介绍了无法隐藏搜索查看iconfiedbydefault的虚拟键盘(假)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有设定为扩张在默认情况下使用默认的搜索查询,但我不希望低于codeI虚拟keyboard.In搜索视图试图在 onCreateOptionsMenu ,但仍隐藏键盘键盘是可见的。

I have a search view which is set as expanded by default with default search query but i don't want the virtual keyboard.In below code i tried to hide keyboard in onCreateOptionsMenu but still keyboard is visible.

imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    MenuItem item = menu.findItem(R.id.menu_search);
    item.expandActionView();
    mSearchView = (SearchView) item.getActionView();
    mSearchView.setIconifiedByDefault(false);
    mSearchView.setQuery(query, true);
    imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);

我使用的福尔​​摩斯搜索视图控件。任何建议,隐藏虚拟keyboard.What我做错了什么?

I am using sherlock search view widget. any suggestion to hide the virtual keyboard.What i am doing wrong?

推荐答案

由Parnit的回答启发,我已经找到一个更好的方法,该方法也适用,更美观:

Inspired by Parnit's answer, I've found a better method, which also works and is more beautiful:

mSearchView.clearFocus();

这篇关于无法隐藏搜索查看iconfiedbydefault的虚拟键盘(假)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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