如何强制 AutoCompleteTextView 更新下拉菜单的高度?

发布于 2024-10-12 21:59:27 字数 213 浏览 9 评论 0原文

我的应用程序中有一个 AutoCompleteTextView,它连接到远程站点以获取建议。在获取建议时,我会显示一个项目列表,其中显示“正在搜索,请稍候”。请求完成后,我更新建议列表适配器并调用 notifyDataSetChanged

然后列表内容更改为新建议(如预期),但不知何故列表的高度仍为 1 个单元格,因此只有顶部建议可见。如何强制视图重新计算下拉高度?

I have an AutoCompleteTextView in my app that connects to a remote site to fetch suggestions. While suggestions are fetched I show a list of one item saying "searching, please wait". After the request completes, I update the suggestion list adapter and call notifyDataSetChanged.

Then the list contents changes to new suggestions (as expected), but somehow the list remains 1 cell in height, so that only the top suggestion is visible. How to force the view to re-calculate the dropdown height?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二货你真萌 2024-10-19 21:59:27

似乎 showDropDown() 强制重新评估建议列表高度。不幸的是,它也迫使它显示出来,但就我的目的而言,这是可以接受的。

It seems that showDropDown() forces re-evaluation of the suggestion list height. Unfortunately, it also forces it to show, but for my purposes it was acceptable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文