早上好, 我目前有一个自定义Google places autocomplete与AutoCompleteTextView运行,但我需要实现它与以下库Floatingsearchview,但我找不到办法做到这一点,让我们看看你是否可以帮我。Google Places自动填充与Floatingsearchview
感谢
早上好, 我目前有一个自定义Google places autocomplete与AutoCompleteTextView运行,但我需要实现它与以下库Floatingsearchview,但我找不到办法做到这一点,让我们看看你是否可以帮我。Google Places自动填充与Floatingsearchview
感谢
使用上进行此
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
从这里的浮动搜索示例的示例https://github.com/arimorty/floatingsearchview/blob/master/sample/src/main/java/com/arlib/floatingsearchviewdemo/data/DataHelper.java它为适配器提供了自定义筛选器。我相信你可以使用Google API的自动完成预测模型。
请在此处看样本 https://github.com/googlesamples/android-play-places/tree/master/PlaceCompleteAdapter他们如何使用Google API和ArrayAdapter的自定义过滤器。您可以将此示例中的自定义过滤器提供给floatingsearchview。
你到目前为止尝试过什么? – FWeigl