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.

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
setCountry(String country)
Restricts the autocomplete results to a particular country.
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)
Restricts the autocomplete results to the given place type.

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 setCountry (String country)

Restricts the autocomplete results to a particular country.

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)

Restricts the autocomplete results to the given place type.

Parameters
typeFilter