AutocompleteSupportFragment

public class AutocompleteSupportFragment extends Fragment

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
onCreate(Bundle savedInstanceState)
void
void
void
onViewCreated(View view, Bundle savedInstanceState)
AutocompleteSupportFragment
setActivityMode(AutocompleteActivityMode mode)
Sets the type of activity to open when a user initiates a query.
AutocompleteSupportFragment
AutocompleteSupportFragment
setCountries(List<String> countries)
Sets countries to restrict results to.
AutocompleteSupportFragment
setCountry(String country)
This method is deprecated. Use setCountries(List) instead.
AutocompleteSupportFragment
setHint(CharSequence hint)
Sets the hint text to display in the search input field when there is no text entered.
AutocompleteSupportFragment
setLocationBias(LocationBias locationBias)
Biases the autocomplete results to a particular area.
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
setText(CharSequence text)
Sets the text to display in the search input field.
AutocompleteSupportFragment
setTypeFilter(TypeFilter typeFilter)
This method is deprecated. Use setTypesFilter(List).
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 onCreate (Bundle savedInstanceState)

Parameters
savedInstanceState

public void onResume ()

public void onSaveInstanceState (Bundle bundle)

Parameters
bundle

public void onViewCreated (View view, Bundle savedInstanceState)

Parameters
view
savedInstanceState

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)

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 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