如何在Autocomple.intentBuilder中过滤城市

时间:2019-11-03 05:10:37

标签: android

Intent intent = new Autocomplete.IntentBuilder(
                AutocompleteActivityMode.OVERLAY, fields)
                .setTypeFilter(TypeFilter.CITIES)
                .setCountry("IN")
                .build(this);
        startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);

在setTypeFiler中不过滤它只是显示城市

1 个答案:

答案 0 :(得分:0)

使用它并根据需要设置setTypeFilder

AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder()
       .setTypeFilter(Place.TYPE_COUNTRY)
       .setCountry("IN")
       .build();
Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
       .setFilter(autocompleteFilter)
       .build(this)
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);