2017-03-08 32 views
0

我想在用於顯示位置的PlaceAutocompleteFragment中顯示關閉按鈕(X標記)。我如何做到這一點。使關閉按鈕(X標記)在PlaceAutocompleteFragment中可見

下面是XML片段:

<android.support.v7.widget.CardView 
      android:id="@+id/cardview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:visibility="gone"> 

      <fragment 
       android:id="@+id/autocomplete_fragment_second" 
       android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

     </android.support.v7.widget.CardView> 

回答

1
PlaceAutocompleteFragment mAutoCompleteFragment = (PlaceAutocompleteFragment) 
      getFragmentManager().findFragmentById(R.id.feed_place_autocomplete_fragment); 

ViewGroup autoCompleteFragmentView = (ViewGroup) mAutoCompleteFragment.getView(); 
    int clearButtonId = com.google.android.gms.R.id.place_autocomplete_clear_button; 
    View mClearAutoCompleteButton = autoCompleteFragmentView.findViewById(clearButtonId); 

這是你如何讓參照該按鈕,現在只要你想,你可以改變它的知名度。

相關問題