问题
Hi I'm new to android and am setting up the autocomplete code for the places api. I was following the google dev instructions on their website and ran into a problem that I can't seem to find any answers on.
I can't seem to find any info on what i am supposed to put for ID and NAME on the first line. There are no auto complete suggestions that come up and I haven't been able to find any info on it on the official documentation. I believe I have imported everything that I need to as I don't have any errors anywhere else in the code.
This is the guide I am following. I am in the section to add the autocomplete by using an intent. https://developers.google.com/places/android-sdk/autocomplete
val location = findViewById<View>(R.id.location_button)
location.setOnClickListener {
val fields = listOf(Place.TYPE_RESTAURANT.ID,Place.TYPE_RESTAURANT.NAME)
val intent = Autocomplete.IntentBuilder(
AutocompleteActivityMode.OVERLAY, fields).build(this)
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE)
回答1:
You need to use Place.Field as documented here. Like this:
val fields = listOf(Place.Field.ID,Place.Field.NAME)
Hope this helps!
来源:https://stackoverflow.com/questions/60748705/places-api-autocomplete-problems