开发者

Android - always enable search box

I am making a dictionary program and the problem I have faced so far is getting a "search box" to be enabled at all times while the progr开发者_StackOverflow社区am is running. In my case, when you run the program, it displays a black screen with nothing there. The user has to press the search button to bring up the search box. How can I make it so that the user won't have to press that button?


You have a couple options here.

  1. You can invoke the search dialog in your main Activity's onCreate() by calling: onSearchRequested(). However, if the user hits the back button at any point in the search dialog, it will dismiss the search dialog and the user will have to hit the search button to bring it back up.
  2. You could create an AutoCompleteTextView that will handle the searching & displaying of the dictionary items. This will be a little more involved, but will guarantee that the "search box" will always be displayed (and the user won't be able to dismiss it).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜