Android 无法在MapsActivity中使用PlaceAutoCompleteFragment

Android 无法在MapsActivity中使用PlaceAutoCompleteFragment,android,autocomplete,placeautocompletefragment,Android,Autocomplete,Placeautocompletefragment,我是Android应用程序开发新手。我正在尝试在“地图”活动的顶部使用PlaceAutoCompleteFragment,我正在使用此链接 一切正常,但只要我点击搜索框,键盘就会出现一秒钟,然后它就会消失,搜索框中的焦点也会消失。 所以我不能打字和搜索。 请帮忙 下面是我的java代码。 import android.support.v4.app.FragmentActivity; import android.os.Bundle; import android.util.Log; import

我是Android应用程序开发新手。我正在尝试在“地图”活动的顶部使用PlaceAutoCompleteFragment,我正在使用此链接

一切正常,但只要我点击搜索框,键盘就会出现一秒钟,然后它就会消失,搜索框中的焦点也会消失。 所以我不能打字和搜索。 请帮忙

下面是我的java代码。

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlaceAutocompleteFragment;
import com.google.android.gms.location.places.ui.PlaceSelectionListener;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

    private GoogleMap mMap;
    PlaceAutocompleteFragment placeAutoComplete;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);

        placeAutoComplete = (PlaceAutocompleteFragment)getFragmentManager().findFragmentById(R.id.place_autocomplete);
        placeAutoComplete.setOnPlaceSelectedListener(new PlaceSelectionListener() {
            @Override
            public void onPlaceSelected(Place place) {
                Log.d("Maps", "Place selected: " + place.getName());
            }

            @Override
            public void onError(Status status) {
                Log.d("Maps", "An error occurred: " + status);
            }
        });

        SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
    }
}
这里是xml代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity"
android:orientation="vertical"
android:weightSum="1">

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

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.manzer.serachtextviewmap.MapsActivity" />

</LinearLayout>