是否可以对 AutoCompleteTextView 使用两个不同的过滤器

发布于 2024-11-17 18:50:50 字数 374 浏览 7 评论 0原文

我正在开发一个小型 Android 应用程序的搜索栏。 我就遇到了这个问题,快一个星期了也搞不明白。

基本思想是当用户在我的搜索栏上输入时,我想为用户提供一些搜索建议。 这是一个非常标准的 AutoCompleteTextView 问题。

但这里很复杂,因为我有两个不同的数据源想要向用户建议。
第一个数据 (localData) 速度很快,我想在用户输入内容时直接向用户建议,第二个数据 (remoteData) 我将发送一个 Internet API 请求来检索数据并将数据附加到前一个数据,更新 dropDownList。

因此,我希望有两个线程来执行过滤,并且将运行两次publishResults,一次用于本地,另一次用于远程请求。

有人有什么建议吗?

I am working on a search bar of a small Android app.
I met this problem and I can't figure it out almost a week.

The basic idea is when user is typing on my search bar, I want to provide some search suggest for the users.
It is pretty a standard AutoCompleteTextView problem.

But it is complicated here for I have two different data source want to be suggested to users.
The first data (localData) is kind of fast and I want to suggest to users directly when user type something, and the second data (remoteData) I will send an Internet API request to retrieve the data and append the data to the previous one and update the dropDownList.

So I want to have two threads to performFiltering and the publishResults will be run two times, one is for local and another one is for remote request.

Is there anyone has any suggestions?

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

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

发布评论

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

评论(2

我是男神闪亮亮 2024-11-24 18:50:50

好吧,我相信,这有点不可能。您可以对结果列表进行排序并将其绑定到 ACTV。

您可以做的是,在屏幕上隐藏一个不可见的容器,并在打字时显示该容器。 =] 并交换回正常的文本视图。

Well I believe, that one is kinda impossible. You can sort your list of results and bind that to the ACTV.

What you can do is, hide an invisible container on the screeen and show that one while typing. =] And swap back to normal textview.

烟凡古楼 2024-11-24 18:50:50

我在publishResults中添加了一个asynctask来实现我的目标。

当用户输入时,首先下拉列表将立即返回本地建议,并执行异步任务。当我的API请求返回结果时,它会更新onPostExecute中的内容

I added an asynctask in the publishResults to achieve my goal.

When user is typing, firstly the dropdownlist will return the local suggest immediately, and will execute an asynctask. When my API request return the result, it will update the contents in the onPostExecute

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