高级自动完成文本视图。多对一映射
我希望自动完成视图显示同一文本项目的多个项目。
IE。使用输入数据 {{a,b,c,d}, {e,f,g,h}},用户可以搜索并开始输入 b,但只能从 a,b,c,d 中找到 1 项显示在自动完成部分。
我该怎么办呢?
谢谢
I want the autocomplete view to display multiple items for the same text item.
ie. with an input data, {{a,b,c,d}, {e,f,g,h}} the user could search and start typing in b, but only 1 item from a,b,c,d would be displayed in the autocomplete section.
How would I go about this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现我可以通过像平常一样将所有元素添加到 autocompletetextview 来解决这个问题。
但是,对于具有“别名”的项目,我将它们作为 1 个项目放入,并用分隔符和空格分隔。该空间允许使用正常功能选择项目。然后,我对每个项目使用了一个自定义视图,该视图标识了正在输入字符串的哪个“部分”,并在下拉项目中显示该部分。
对于我的解决方案,我隐藏了 autocompletetextview,但您也可以只调用 setText 来覆盖默认行为。
I found I could solve this problem by adding all the elements to the autocompletetextview like normal
However, for the items that had "aliases" I put them in as 1 item, separated by a separator character and a space. The space allowed the item to be selected using the normal functionality. Then I used a custom view for each of the items which identified which 'part' of the string was being entered and displayed that part in the dropdown item.
For my solution, I then hide the autocompletetextview, but you could also just call setText to overwrite the default behavior.