Android - always enable search box - android

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 program 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.
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.
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).

Related

how to remove the close button from popupkeyboard in android

I am customizing the android keyboard after downloading the sample keyboard code from developer.android.com. I want to customize the layout of the popup window after a user made a long press on a given key, onLongPress(key popupKey). Particularly, I want to get ridoff the close button at the end of the popup keys and want to make the window close when the user clicks outside it. But, I can't figure out how to get access to the popup window. Please give me some hints.
I finally figure it out myself and want to share for anyone interested.
I was not able to get the close button and get rid off it. But, what I got easier is creating a PopupWindow having multiple buttons whose labels are the popup characters taken from the key parameter passed to onLongPress().
This way I was able to display only the popup characters and close the window when the user selects on of them or presses outside of the window.
Cheers!

How do I automatically remove focus from searchview in android app after clicking on it

I m making book finder app.
step1: i clicked on search button and activity is waiting for my book title
step2: i input some book title
step3: the focus still stays on this search button, i have to click on screen to make it go away.
is there way to automatically loose focus on last widget i clicked on?
You probably just want to call requestFocus() on your book list whenever a search completes (however, if there are no results, you may want to re-open your search box, or do so after a delay). There is also a OnFocusChangedListener which might be of help if requesting focus on your list after serving up results does't work for some reason.

How can I call search dialog with an ImageView?

I have to call search dialog when I press a button into the activity or when I press an ImageView, not with the hardware button like in this post:
How can I call search dialog on button click in android?
Please if you have the code or a tutorial, thanks a lot.
In the docs for the search dialog under "Invoking the search dialog"
...However, some devices do not include a dedicated SEARCH button, so you should not assume that it's always available. When using the search dialog, you must always provide another search button in your UI that activates the search dialog by calling onSearchRequested()...
So you should be able to put onSearchRequested(); inside your click listener to when the image is pressed this method call should launch the search dialog for you.

How to blur background of search dialog?

I’ve created a search activity in my app, in the standard Android way, without custom suggestions. When a user starts typing text or presses the search button, they get a search dialog with search box, something like figure 1 from here:
http://developer.android.com/guide/topics/search/search-dialog.html
You’ll notice in the background is the previous activity, the words “abide”, etc.
My problem is that the previous activity is shown clear as day behind the search dialog, and its confusing for users, because users think all that is still active, and they try to press on it, but it just cancels the search dialog. And it distracts the user from the search task (are those search results, they may wonder?).
Question: how to blur (make out of focus) or darken the previous activity?
I actually see this in some app’s search screens.
I found a simple way to blur the background of the search dialog:
Basically it's just adding a (half) transparent view over the ListView (or what is under the dialog) and hide it by default. If the search dialog appears (calling onSearchRequested()) it is set to visible, if it disappears it's set back to gone (invisible).
Check out the details at my blog: http://mavistechchannel.wordpress.com/2011/08/13/blur-background-android-search-dialog/
Assuming you got dialog from a Dialog.Builder, use the following:
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

How to activate option menu when search box is displayed? (SearchManager)

I am trying to build a quick search box. it is basically a widget. Upon clicking, it pops up the quick search box and launch the browser with query string. No activity except searchactivity.
And also added codes for 'recent query suggestion' But having a problem to have menu for 'clear history' Here is what I wanted to implement. When quick search box is displayed, by pressing menu button, I want option menu to be popped up, keypad to be disappeared, quick search box to be stayed.
the implementation of google sample code - Searchable dictionary is not what I want to implement. It starts an activity with instruction message and when a user presses the search button or menu button, it pops up the quick search box. Mine is when it runs from a widget, the quick search box is popped up right away just like the google search widget.
How can I override onCreateOptionMenu on searchmanager? Or is there any way to activate option menu when the searchmanager is activated?
Please take a look at the images below. the second image is what I want to implement upon clicking menu button.
What you need to do is make the search button launch the default search activity when it is pressed. And make it sorta match the existing search dialog style. You can notice this is how the official Twitter client works. You can use apktool (google it) to take a look at the official Twitter clients resource files to get a better idea of how this can be accomplished.

Categories

Resources