Implements a fragment that presents a search box button to the user, which presents a search box
UI when clicked. As the user types, the autocomplete service returns Place
predictions
for places such as businesses, addresses and points of interest. When the user selects a place,
the autocomplete service returns the response via the PlaceSelectionListener
.
Inherited Field Summary
Public Constructor Summary
Public Method Summary
static AutocompleteSupportFragment |
newInstance()
Create a new autocomplete fragment with default config.
|
void |
onActivityResult(int requestCode, int resultCode, Intent data)
|
void | |
void |
onResume()
|
void |
onSaveInstanceState(Bundle bundle)
|
void | |
AutocompleteSupportFragment |
setActivityMode(AutocompleteActivityMode mode)
Sets the type of activity to open when a user initiates a query.
|
AutocompleteSupportFragment | |
AutocompleteSupportFragment | |
AutocompleteSupportFragment | |
AutocompleteSupportFragment |
setHint(CharSequence hint)
Sets the hint text to display in the search input field when there is no text entered.
|
AutocompleteSupportFragment | |
AutocompleteSupportFragment |
setLocationRestriction(LocationRestriction locationRestriction)
Restricts the autocomplete results to a particular area.
|
AutocompleteSupportFragment |
setOnPlaceSelectedListener(PlaceSelectionListener listener)
Sets a listener that will be notified when a place is selected.
|
AutocompleteSupportFragment |
setPlaceFields(List<Place.Field> placeFields)
Sets the desired fields of the
Place object returned from selecting an autocomplete
result. |
AutocompleteSupportFragment |
setRegionCode(String regionCode)
Sets the unicode country/region code (CLDR) of the location where the request is coming from.
|
AutocompleteSupportFragment | |
AutocompleteSupportFragment | |
AutocompleteSupportFragment |
setTypesFilter(List<String> placeTypes)
Sets the filter that restricts the type(s) of results returned from the response.
|
Inherited Method Summary
Public Constructors
public AutocompleteSupportFragment ()
Public Methods
public static AutocompleteSupportFragment newInstance ()
Create a new autocomplete fragment with default config.
public void onActivityResult (int requestCode, int resultCode, Intent data)
Parameters
requestCode | |
---|---|
resultCode | |
data |
public void onResume ()
public AutocompleteSupportFragment setActivityMode (AutocompleteActivityMode mode)
Sets the type of activity to open when a user initiates a query.
Parameters
mode |
---|
public AutocompleteSupportFragment setCountries (String... countries)
See setCountries(List)
.
Parameters
countries |
---|
public AutocompleteSupportFragment setCountries (List<String> countries)
Sets countries to restrict results to.
This must be a list of ISO 3166-1 Alpha-2 country codes (case insensitive). If no countries are set, no country filtering will take place.
This will override values set with setCountry(String)
.
Up to five countries are supported. See the components
parameter here.
Parameters
countries |
---|
public AutocompleteSupportFragment setCountry (String country)
This method is deprecated.
Use setCountries(List)
instead.
See setCountries(String...)
for details.
This will override countries set with setCountries(String...)
.
Parameters
country |
---|
public AutocompleteSupportFragment setHint (CharSequence hint)
Sets the hint text to display in the search input field when there is no text entered.
If the hint is unset or explicitly set to null, the hint text will be set to the default value.
Parameters
hint |
---|
public AutocompleteSupportFragment setLocationBias (LocationBias locationBias)
Biases the autocomplete results to a particular area.
Parameters
locationBias |
---|
public AutocompleteSupportFragment setLocationRestriction (LocationRestriction locationRestriction)
Restricts the autocomplete results to a particular area.
Parameters
locationRestriction |
---|
public AutocompleteSupportFragment setOnPlaceSelectedListener (PlaceSelectionListener listener)
Sets a listener that will be notified when a place is selected.
Parameters
listener | The listener that should be notified. |
---|
public AutocompleteSupportFragment setPlaceFields (List<Place.Field> placeFields)
Sets the desired fields of the Place
object returned from selecting an autocomplete
result.
Read more about Place Data Fields.
Parameters
placeFields |
---|
public AutocompleteSupportFragment setRegionCode (String regionCode)
Sets the unicode country/region code (CLDR) of the location where the request is coming from.
The region code field is only supported by Places API (New). Please enable your API key for the Places API (New) in the Google Cloud Console to use region code. If you do not enable your API key for the Places API (New), the region code will not affect the results.
Parameters
regionCode |
---|
public AutocompleteSupportFragment setText (CharSequence text)
Sets the text to display in the search input field.
Parameters
text |
---|
public AutocompleteSupportFragment setTypeFilter (TypeFilter typeFilter)
This method is deprecated.
Use setTypesFilter(List)
.
Restricts the autocomplete results to the given place type.
Parameters
typeFilter |
---|
public AutocompleteSupportFragment setTypesFilter (List<String> placeTypes)
Sets the filter that restricts the type(s) of results returned from the response.
Up to 5 place types are supported. A comprehensive list of the supported types can be found
in PlaceTypes
. The type collections
specified in table 3 must be passed in as solo entries and cannot be combined with any other
entries from table 1 or 2.
This will override setTypeFilter(TypeFilter)
if both are used.
Parameters
placeTypes |
---|