Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个AutoCompleteTextView使用 anArrayAdapter<android.location.Address>作为它的Adapter.
AutoCompleteTextView
ArrayAdapter<android.location.Address>
Adapter
适配器的getView方法是迭代Address getAddressLine(i)并构建一个String来设置View。问题是一旦用户点击建议,就会输入toString()ofAddress而不是 my String。我怎样才能改变这种行为?
getView
Address
getAddressLine(i)
String
View
toString()
这是它发生的地方,但我不知道如何改变它。 这里建议子类化?
在第 839 行,您正在调用 mFilter.convertResultToString(selectedItem); 这就是为什么你得到地址的 toString() 的原因。如果要在视图中输入字符串,则需要通过此方法返回视图中使用的值。
Address address = (Address) selectedItem; return address.getAddressLine(i);