1
<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"/>

I am reading the fragment by

PlaceAutoCompleteFragment fromCity = (PlaceAutocompleteFragment)getFragmentManager().findFragmentById(R.id.source);

View destinationClearView = fromPlace.getView().findViewById(R.id.place_autocomplete_clear_button);

But destinationClearView.setVisibility(View.INVISIBLE) is not working, How to acheive that?

  • Try to more elaborate. – Přemysl Šťastný Aug 11 '16 at 15:16
  • PlaceAutoCompleteFragment fromCity = (PlaceAutocompleteFragment)getFragmentManager().findFragmentById(R.id.source); fromCity.setHint(getString(R.string.your_location)); fromCity.setOnPlaceSelectedListener(new PlaceSelectionListener() { Override public void onPlaceSelected(Place place) { //Do something with place } Override public void onError(Status status) { //Do something on error } }); Here I want to click on that widget programatically – sanyasirao mopada Aug 11 '16 at 17:30
  • @PřemyslŠťastný and How can I get callback when user clears the place by clicking on clear icon – sanyasirao mopada Aug 11 '16 at 17:31
  • @PřemyslŠťastný I am accessing clear view by destinationClearView = destinationWidget.getView().findViewById(R.id.place_autocomplete_clear_button); And I added onclick listener to as I have to do some functionality, But it's not excecuting methods in parent fragment that is clearing the text, hiding the clearbutton How can I achieve that? – sanyasirao mopada Aug 12 '16 at 06:06
  • Write(edit) it to question, it will go throw sys one again. You will get better answers. :) – Přemysl Šťastný Aug 12 '16 at 06:13
  • @PřemyslŠťastný can I change the visibility of that edittext, clear view – sanyasirao mopada Aug 12 '16 at 06:16
  • @PřemyslŠťastný I edited the question – sanyasirao mopada Aug 12 '16 at 06:21

1 Answers1

0

It's not good way, but it's work.

View close = viewOfFragment.findViewById(R.id.place_autocomplete_clear_button);
ViewsUtils.setVisible(false, close);
lp = (LinearLayout.LayoutParams) close.getLayoutParams();
lp.height = 1;
lp.width = 1;
close.requestLayout();
Yura Shinkarev
  • 5,134
  • 7
  • 34
  • 57