Expand and give focus to SearchView automatically

后端 未结 17 2444
囚心锁ツ
囚心锁ツ 2020-12-02 18:21

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 scree

17条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 18:49

    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.

提交回复
热议问题