I get and fetch current location and selected location but when i pressed cancel cross button it will clear it all, but now cannot clear from variable.. please help me Thanx in advance
Place Autocomplete fragment clear button set visibility gone
3k views Asked by Shaalz At
2
There are 2 answers
0
On
This solution has worked for me:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<fragment android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:id="@+id/view_callback"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="right|center_vertical"
android:background="@android:color/transparent"/>
</FrameLayout>
I have put a transparent view over the PlaceAutocompleteFragment. This view should cover the cancel button. Then, in Activity/Fragment, after obtining view reference:
closeCallback.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
autocompleteFragment.setText("");
return true;
}
});
This solution works because when you put a empty string we obtain the same result.
You can not set its visibility gone. and there is no listener also.
May be it will be available in google next update.
Not a correct solution but if you really need it. You can create a white view on cross button using relative layout so the user is not able to see the cross button.
and put a clicklistener on it so that cross is not clickable