放置API自动填充问题 [英] Places API autocomplete problems

查看:97
本文介绍了放置API自动填充问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android新手,正在为places api设置自动完成代码.我正在按照Google开发人员网站上的说明进行操作,遇到了一个问题,我似乎找不到任何答案.

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.

我似乎找不到第一行应该输入的ID和NAME信息.没有自动完成建议,我还没有在官方文档中找到任何建议的信息.我相信我已经导入了我需要的所有内容,因为我在代码中的其他任何地方都没有任何错误.

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.

这是我正在遵循的指南.我在本节中通过使用意图来添加自动完成功能. https://developers.google.com/places/android-sdk/autocomplete

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)

推荐答案

您需要使用 Place.Field ,如

You need to use Place.Field as documented here. Like this:

val fields = listOf(Place.Field.ID,Place.Field.NAME)

希望这会有所帮助!

这篇关于放置API自动填充问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆