I am trying to inflate an AutoCompleteSupportFragment which uses Google Places API, in an onClick event of an editText.
I want to inflate that fragment when the editText is clicked, so that the user might enter a location, select from the suggestions in the auto complete fragment and the location name will be shown on the editText.
I checked this link here, but it didnt work for me.
places_auto_complete_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/place_autocomplete_fragment"
android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment" />
how I am trying to inflate it
sourceEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LayoutInflater layoutInflater = getLayoutInflater();
layoutInflater.inflate(R.layout.places_auto_complete_fragment,addTripLinearLayout,false);
}
});
Any help is appreciated. Thanks