PlaceAutocompleteFragment 显示 "Can't load searching result"
PlaceAutocompleteFragment show "Can't load searching result"
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setBoundsBias(new LatLngBounds(
new LatLng(-33.880490, 151.184363),
new LatLng(-33.858754, 151.229596)));
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build();
autocompleteFragment.setFilter(typeFilter);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
Toast.makeText(getApplicationContext(), "Place:" + place.getName(), Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
Toast.makeText(getApplicationContext(), "error" + status, Toast.LENGTH_SHORT).show();
}
});
搜索无效。当我在搜索文本框中键入地名时。它显示 "Can't load the searching result"。我无法解决它。请帮我。谢谢
按照这个步骤
在项目中添加依赖项gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
在main中添加依赖Gradle
classpath 'com.google.gms:google-services:3.0.0'
最后你需要在你的项目中添加google-services.json文件
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setBoundsBias(new LatLngBounds(
new LatLng(-33.880490, 151.184363),
new LatLng(-33.858754, 151.229596)));
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build();
autocompleteFragment.setFilter(typeFilter);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
Toast.makeText(getApplicationContext(), "Place:" + place.getName(), Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
Toast.makeText(getApplicationContext(), "error" + status, Toast.LENGTH_SHORT).show();
}
});
搜索无效。当我在搜索文本框中键入地名时。它显示 "Can't load the searching result"。我无法解决它。请帮我。谢谢
按照这个步骤
在项目中添加依赖项gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
在main中添加依赖Gradle
classpath 'com.google.gms:google-services:3.0.0'
最后你需要在你的项目中添加google-services.json文件