我正在尝试使用以下代码从Google地方过滤自动填充结果:

List<Integer> filters = new ArrayList<Integer>();
filters.add(AutocompleteFilter.TYPE_FILTER_ADDRESS);
filters.add(AutocompleteFilter.TYPE_FILTER_CITIES);
mAutocompleteFilter = AutocompleteFilter.create(filters);


但它无法解析方法AutocompleteFilter.create。

build.gradle:

compile "com.google.android.gms:play-services-maps:11.4.2"
compile "com.google.android.gms:play-services-auth:11.4.2"
compile "com.google.android.gms:play-services-location:11.4.2"
compile "com.google.android.gms:play-services-places:11.4.2"


是因为版本11.4.2吗?我不想降级。在此AutocompleteFilter中是否还有其他选择可以使用多个整数?

最佳答案

没有create方法,而是使用AutocompleteFilter.Builder

From Docs


  使用AutocompleteFilter.Builder创建一个新的AutocompleteFilter。


mAutocompleteFilter = new AutocompleteFilter.Builder()
        .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
        .setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
        .build();

08-25 23:32