展开并给予重点搜索查看自动 [英] Expand and give focus to SearchView automatically
问题描述
我开发了用户presses在动作条
和搜索查看$ C搜索图标的应用程序$ C>在屏幕的顶部可见。
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屋!