Casting fragment to AutoCompleteFragment gives error

I want to initialise my place_autocomplete_fragment, but my getFragmentManager().findFragmentById() returns a casting error (cannot convert Fragment to PlaceAutocompleteFragment). I have already tried changing my Fragment import, but it did not solve anything for me.

PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);

(this code returns: Inconvertible types; cannot cast 'android.support.v4.app.Fragment to 'com.google.android.gms.location.places.ui.PlaceAutocompleteFragment')

Upvotes: 0

Views: 48

Answers (1)

Solved, had to use SupportPlaceAutocompleteFragment instead of PlaceAutocompleteFragment.

Upvotes: 0

Related Questions