Application to implement:
User is prompted to input his source location, after that user is prompted to input his destination location. After completion, a route will appear between source and destination.
Implemented so far
About Textbox: The textbox I am using is a place autocomplete from Places API from google itself. This widget at any length of input shows specific place hints relative to the input. I am basically using the fragment implementation of this autocomplete textbox.
Problem: Now the problem I am facing is that I want my textbox that was inputting source should now input destination. What should i do change the input type?
Code:
.xml file
<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" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mazik.ahmed.androidappontheway.MapsActivity" />
.java file
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
LatLng latlng = new LatLng(place.getLatLng().latitude, place.getLatLng().longitude);
mMap.addMarker(new MarkerOptions().position(latlng).title(place.getName().toString())
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET)));
}
@Override
public void onError(Status status) { }
});
What I want is that the autocomplete widget prompt for a re-input after assuring the source has been selected.