自动谷歌PlaceAutocompleteFragment的触发

问题描述:

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

我被自动谷歌PlaceAutocompleteFragment的触发

PlaceAutoCompleteFragment fromCity =(PlaceAutocompleteFragment)getFragmentManager()findFragmentById(R.id.source)读取所述片段。

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

但destinationClearView.setVisibility(View.INVISIBLE)不起作用,该如何实现?

+0

试着更详细一点。 –

+0

PlaceAutoCompleteFragment fromCity =(PlaceAutocompleteFragment)getFragmentManager()。findFragmentById(R.id.source); fromCity.setHint(getString(R.string.your_location)); fromCity.setOnPlaceSelectedListener(新PlaceSelectionListener(){ 覆盖 公共无效onPlaceSelected(地点位置){// 不要放弃地方 } 覆盖 公共无效onerror的(状态的状态){// 做的东西就差错 东西} }); 在这里,我想对控件编程点击@ –

+0

和PřemyslŠťastný我怎样才能得到回调时,用户通过点击清除图标 –

这不是好的方法,但它的工作。

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();