早上好, 我目前有一个使用AutoCompleteTextView运行的自定义Google places autocomplete,但我需要使用以下库Floatingsearchview来实现它,但是我找不到这样做的方法,让我们看看你是否可以帮助我。< / p>
感谢
答案 0 :(得分:0)
使用此
try {
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.build(this);
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
} catch (GooglePlayServicesRepairableException e) {
// TODO: Handle the error.
} catch (GooglePlayServicesNotAvailableException e) {
// TODO: Handle the error.
}
选择地点的结果
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
Log.i(TAG, "Place: " + place.getName());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
// TODO: Handle the error.
Log.i(TAG, status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
}
}
}
链接https://developers.google.com/places/android-api/autocomplete#get_place_predictions_programmatically
答案 1 :(得分:0)
从此处的floatingsearchview示例https://github.com/arimorty/floatingsearchview/blob/master/sample/src/main/java/com/arlib/floatingsearchviewdemo/data/DataHelper.java,它为适配器提供自定义过滤器。我相信您可以使用Google API的AutocompletePrediction模型。
请在此处查看示例 https://github.com/googlesamples/android-play-places/tree/master/PlaceCompleteAdapter他们如何在Google API和ArrayAdapter中使用自定义过滤器。您只需将此示例中的自定义过滤器提供给floatingsearchview。