2016-02-26 27 views
1

我得到並獲取當前位置和所選的位置,但是當我按下了取消十字按鈕,它會清除這一切,但現在還不能從變量清楚..請幫助我 Thanx提前地方自動填充碎片清除按鈕設置可見不見了

+0

autoCompleteTextView.setText(「」);簡單,因爲 –

+0

無法從變量意味着?? –

+0

如何檢查空文本到位autocomplete片段?當我點擊交叉(取消)按鈕時,jzt清除但不能從變量中清除當前位置。我想刪除十字按鈕。 Plz幫助我@ Bajirao Shinde – Shaalz

回答

0

您無法將其可見性設置消失。 也沒有聽衆。
可能會在谷歌下次更新中提供。

不是一個正確的解決方案,但如果你真的需要它。 您可以使用相對佈局在十字按鈕上創建白色視圖,以便用戶無法看到十字按鈕。

<RelativeLayout 
     android:layout_below="@+id/actionBar" 
    android:id="@+id/ll1" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/_40sdp" 
     android:alpha=".9" 
    android:background="@drawable/home_page_search" 
    android:layout_margin="10dp" 

    > 

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


     <View 
      android:id="@+id/view1" 
      android:layout_width="@dimen/_50sdp" 
      android:layout_height="match_parent" 
      android:layout_alignParentRight="true" 
      android:background="@color/white" 
      android:layout_margin="@dimen/_5sdp" 
      /> 


    </RelativeLayout> 

,並把clicklistener它使十字無法點擊

0

該解決方案爲我工作:

<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> 

我已經把在PlaceAutocompleteFragment透明視圖。該視圖應該包含取消按鈕。然後,在活動/片段,obtining觀看基準後:

closeCallback.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      autocompleteFragment.setText(""); 
      return true; 
     } 
    }); 

此解決方案,因爲當你把一個空字符串,我們得到了相同的結果。