Android 中 AutoCompleteTextView 的结果
我有一个 AutoCompleteTextView
,它使用 ArrayAdapter
作为其 Adapter
。
适配器的 getView 方法正在迭代 Address
getAddressLine(i)
并构建一个 String
来设置查看
与。问题是,一旦用户点击建议,就会输入 Address
的 toString()
而不是我的 String
。我怎样才能改变这种行为?
I have an AutoCompleteTextView
which is using an ArrayAdapter<android.location.Address>
as its Adapter
.
The getView
method of the adapter is iterating over the Address
getAddressLine(i)
and building a String
to set the View
with. The problem is once the user clicks on a suggestion, the toString()
of Address
gets entered instead of my String
. How can I change this behavior?
This is where it's happening, but I don't know how to change it. Here it is suggesting to subclass?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在第 839 行,您正在调用 mFilter.convertResultToString(selectedItem);这就是为什么您要获取地址的 toString() 的原因。如果要在视图中输入字符串,则需要从此方法返回视图中使用的值。
On line 839, you are calling mFilter.convertResultToString(selectedItem); which is why you are getting the toString() of the address. If you want to enter the string in your view you need to return the value used in your view from this method.