I have implemented Google's PlaceAutocompleteFragment
in my android app and it looks like this below.
But I want to add a button in the end just how google maps has a microphone.
Below is my code so far:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
>
<fragment
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
</android.support.v7.widget.CardView>
Place select Code:
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
String placeName = place.getName().toString();
LatLng latLng = place.getLatLng();
mMap.addMarker(new MarkerOptions().position(latLng).title(placeName));
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
Log.i(TAG, "An error occurred: " + status);
}
});
A sample code would be nice. Thank you so much :)