我已经以这种方式添加了PlaceAutocompleteFragment -
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setHint("");
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
Log.i("TAG", "Place: " + place.getLatLng());
}
@Override
public void onError(Status status) {
Log.i("TAG", "An error occurred: " + status);
}
});
还在依赖项
中添加compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
在清单中
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
现在,当我点击搜索图标时,我什么都没有打开,也没有在日志中收到任何错误。我不确定我做错了什么。