As you know, the Google Places API allows you to type into a search box and get suggested addresses in a dropdown menu.
In most examples, I've seen people use the Google Places API with an AutoCompleteTextView so that it will display autocomplete suggestions in a dropdown. What I actually want is for the suggestions to fill in a RecyclerView. What is the proper way to do this?
you can use GeoDataApi.getAutocompletePredictions then display those results anyway you wish (ie, in your recyclerview)
see https://developers.google.com/places/android-api/autocomplete#get_place_predictions_programmatically for instructions
how can I create in my android app a button that will automatically put the search suggestion into the search bar, so that when you click on the button, the search bar will be automatically filled with the corresponding text?
An example is shown in the image below.
Have you looked into AutoCompleteTextView? From the docs:
The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
EDIT: If you're using a SearchView, the process is much different. Assuming you've already set up the SearchView, you have to provide search suggestions that the system will display as the user types. These can be recent query suggestions or custom search suggestions.
There are several steps involved, but in a nutshell, you will have to create a Content Provider that takes a search query and serves up a list of suggestions (details here). Once you've done this, you can configure your search bar to fill itself in when the user selects a suggestion (details here).
Hope this helps!
The solution is to call setQueryRefinementEnabled(true) on the SearchView object
Even a Snippet of an android code to Integrate Google Search into an Edit text will be really useful, according to my requirement i don't want the google search data or whatever but only the dropdown so that it will b easier for people to type and don't have to waste time :)
You can see about the componenent is AutoCompleteTextView
An editable text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
Basically what I want to create can be best illustrated from a screenshot.
I have a listview of people just like FB Messenger app. I want the ability for my users to have a search bar like the one shown in the screenshots.
It should have the following properties:
1) Search bar should preview names of people selected in the list view
2) People can be de-selected by hitting backspace on any name in the preview search bar
3) The search bar should be able to filter the bottom list of people as the user types.
I have a solution for propert 3) but I am clueless about the other two.
Please HELP!!!
You should check out this.
This class uses combination of TextWatcher, SpannableString, AutoCompleteTextView and Annotations.
In the system-wide search on my HTC Desire (Froyo), I see a little drop down left to the search input field that allows to select where I want to search (All, web, apps).
How can I implement this in an application of mine? The search tutorial on the Google developer site does not address this.
So in a scenario like the following, taken from the Android docs,
I would like to click on the books and then get some sort of menu to e.g. select "words", "headings" as search mode.
Update: I am not looking for the QuickAction dialog itself, but rather how to attach something to the books icon that reacts on touch, so that I could attach the QuickAction or a new activity or ... And I want to use the standard Android Search Dialog as described in http://developer.android.com/guide/topics/search/search-dialog.html
You can't modify the system's search dialog. So if you want customizations like making a drop-down menu appear when the user touches the icon, you'll have to implement your own dialog. This would make your search non-standard so I wouldn't advise it.
However, if I can't talk you out of it, you can see how Android's built-in search dialog is implemented here:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/SearchDialog.java
In Android 3.x this gets a little easier with the introduction of the SearchView class.
It is just a custom view that get rendered when you hit that button with a fancy animation.
It has nothing to do with the search framework per se. You just show a custom layout (with a fancy animation if you want) and set a value by clicking on one of the icons. Thats it.
I think what your looking for is called a "quickaction dialog".
Here's a tutorial that should have you well on your way.
Updated by question asker (paste of comment):
ah i see. well somehow you need the id of the icon in order to implement the onclicklistener(). you may be stuck just going with a search widget and implementing most by scratch. Or perhaps, with the search dialog implemented and running, use hierarchyviewer to see if the icon has an id. Maybe you'll be in luck and it'll have a unique one. I'm out of ideas for now.
Those options (and their icons) are determined by the searchable items list in the android settings (Settings->Search->Searchable items at least in my phone). If you want to add a search action to that menu, take a look at this:
http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#QSB
Enabling suggestions on a device
When your application is configured to
provide suggestions in Quick Search
Box, it is not actually enabled to
provide suggestions in Quick Search
Box, by default. It is the user's
choice whether to include suggestions
from your application in the Quick
Search Box. To enable search
suggestions from your application, the
user must open "Searchable items" (in
Settings > Search) and enable your
application as a searchable item.
Each application that is available to
Quick Search Box has an entry in the
Searchable items settings page. The
entry includes the name of the
application and a short description of
what content can be searched from the
application and made available for
suggestions in Quick Search Box. To
define the description text for your
searchable application, add the
android:searchSettingsDescription
attribute to your searchable
configuration. For example:
http://developer.android.com/guide/topics/search/searchable-config.html
Quick Search Box attributes
To make your custom search suggestions
available to Quick Search Box, you
need some of the following
attributes:
android:includeInGlobalSearch
Boolean. (Required to provide search suggestions in Quick Search
Box.) Set to "true" if you want your
suggestions to be included in the
globally accessible Quick Search Box.
The user must still enable your
application as a searchable item in
the system search settings before your
suggestions will appear in Quick
Search Box.
android:searchSettingsDescription
String. Provides a brief description of the search suggestions
that you provide to Quick Search Box,
which is displayed in the searchable
items entry for your application. Your
description should concisely describe
the content that is searchable. For
example, "Artists, albums, and tracks"
for a music application, or "Saved
notes" for a notepad application.
android:queryAfterZeroResults
Boolean. Set to "true" if you want your content provider to be invoked
for supersets of queries that have
returned zero results in the past. For
example, if your content provider
returned zero results for "bo", it
should be requiried for "bob". If set
to "false", supersets are ignored for
a single session ("bob" does not
invoke a requery). This lasts only for
the life of the search dialog or the
life of the activity when using the
search widget (when the search dialog
or activity is reopened, "bo" queries
your content provider again). The
default value is false.
So if you want to add an option to search for words or headings, and you have an activity that allows that search, then you can add that Searchable item(s) to the list. They will be available only if the user wants, though.