标签:android android-edittext autocomplete android-search
我在我的应用程序中实现了地方自动完成功能,并在EditText中编写了搜索关键字,以根据搜索地点关键字获取结果.
这里是用于搜索PlaceAutocomplete活动的代码
int PLACE_AUTOCOMPLETE_REQUEST_CODE = 1;
try {
Intent intent =
new
PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
.build(this);
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
} catch (GooglePlayServicesRepairableException e) {
} catch (GooglePlayServicesNotAvailableException e) {
}
当活动启动列表显示空白时.
我想要的是-
已经搜索过的地方应该在活动启动时显示为超级应用程序
解决方法:
您必须在内部应用程序存储(共享首选项,数据库..)或您想要的任何地方保留自动完成结果.基本上,您需要自己实现UI.我认为您无法根据需要自定义PlaceAutocomplete.IntentBuilder.
>为AutocompleteGooglePlaces实施API调用(我们正在为此进行改造)
@GET("/maps/api/place/autocomplete/json")
Call<GoogleAutocompleteResponse> getAutoCompleteSearchResults(@Query("key") String apiKey,
@Query("input") String searchTerm,
@Query("location") String location,
@Query("radius") long radius);
>执行调用(在Enter-click或onTextChange上)
public List<GooglePlaceAutocompleteGeoModel> getAutoCompleteSearchResults(String searchTerm, LatLng center, long radius) {
Call<GoogleAutocompleteResponse> call = googlePlacesRestApiService.getAutoCompleteSearchResults(API_KEY, searchTerm, getLocationStringFrom(center), radius);
try {
GoogleAutocompleteResponse autocompleteResponse = call.execute().body();
List<GooglePlaceAutocompleteGeoModel> autocompleteResponsePredictions = autocompleteResponse.getPredictions();
//Here are your Autocomplete Objects
return autocompleteResponsePredictions;
} catch (IOException e) {
L.e("Error on Google Autocomplete call: " + e.getMessage());
}
return new ArrayList<>();
}
>在您的应用中坚持自动完成结果GoogleAutocompleteResponse的结果并实现逻辑以在UI中显示结果或填充在ListView中
标签:android,android-edittext,autocomplete,android-search 来源: https://codeday.me/bug/20190627/1307630.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。