gpt4 book ai didi

android - 带有自定义 ArrayAdapter 的 AutocompleteTextView

转载 作者:太空狗 更新时间:2023-10-29 15:20:05 24 4
gpt4 key购买 nike

我正在使用自定义 ArrayAdapter 在 AutocompleteTextView 上设置适配器(AddressAdapter 扩展 ArrayAdapter)。

因为我使用下拉列表来显示地址和到实际位置的距离,所以我必须用地址参数化数组适配器。

问题来了:方法

public Address getItem(int position)

给出地址列表的选定项。由于我使用 Address 作为 Adapter 基类,因此当我单击其中一项建议时,TextBox 将填充 Address 类的 toString() 表示。

如何更改此默认行为?

谢谢!

最佳答案

您可以覆盖 getView() 方法来更改每个项目的默认 View 。

您可以提取 TextView 并且由于 getView() 也将位置传递给您,您可以使用它来检索数据对象并操作显示的值.

关于android - 带有自定义 ArrayAdapter 的 AutocompleteTextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8771527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com