展开并给予重点搜索查看自动 [英] Expand and give focus to SearchView automatically

查看:134
本文介绍了展开并给予重点搜索查看自动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了用户presses在动作条搜索查看在屏幕的顶部可见。

I'm developing an application where the user presses the "Search" icon in the ActionBar and a SearchView is made visible at the top of the screen.

我的问题是,搜索查看没有焦点,也扩大了,因此用户必须preSS上的搜索按钮搜索查看来使其膨胀并带出键盘。

My problem is that the SearchView is not in focus nor expanded so the user has to press the search button on the Searchview to make it expand and bring out the keyboard.

应如何解决?

推荐答案

若要在默认情况下,调用 setIconifiedByDefault(假)上展开,当你初始化它的搜索查看(例如,在 onCreateOptionsMenu(..)在prepareOptionsMenu(..))。我在大多数情况下,发现这会给它自动对焦,但如果不是简单地调用不是requestFocus()就可以了。

To make the SearchView expanded by default, call setIconifiedByDefault(false) on it when you initialise it (e.g. in onCreateOptionsMenu(..) or onPrepareOptionsMenu(..)). I've found in most cases this will give it focus automatically, but if not simply call requestFocus() on it too.

这篇关于展开并给予重点搜索查看自动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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