从 android 中的 10,000 个项目列表中选择任何项目

发布于 2024-12-11 02:29:51 字数 407 浏览 5 评论 0原文

我尝试搜索问题,看看是否有与我的问题类似的线索,但到目前为止还没有找到。 我的问题是:我有一个产品列表,其中包含存储在 SQLite 数据库中的约 10,000 个项目。在我的应用程序中,我需要从此列表中搜索任何项目。我有几个选项:

  • 使用 autoCompleteTextView,预加载所有产品,当我输入产品名称时,列表将建议该产品,因此我只需要从建议中进行选择。这是最简单的方法,但我觉得加载 10,000 个项目(甚至将来更多)会非常繁重
  • 当我输入任何字符并单击搜索时,应用程序将从数据库中选择所有产品,并使用该字符作为过滤器。然后将结果集输入到某个列表视图,以便我可以选择任何项目。这种方法可以节省内存,因为应用程序不会将所有项目加载到内存中,而只会加载包含过滤字符的项目。

有没有更好的方法来做到这一点? 谢谢

I try to search through the questions to see if there is any similar thread to my problem but so far haven't found any.
Here is my problem is: I have a list of products which contains ~10,000 items stored in a SQLite db. In my app, I need to search for any item from this list. I have a few options:

  • Use the autoCompleteTextView, with all products preloaded, and as I type the product's name, the list will suggest the product, hence I just need to select from the suggestion. This is the simplest way but I feel 10,000 items (or even more in the future) would be very heavy to load
  • As I type any character and click search, the app will do a select all products from the db with the character as a filter. The result set is then fed to some list view so that i can pick any item. This approach would save the memory as the app won't load all items to the memory but only items that contain the filtering characters.

Is there any better way to do this?
Thanks

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

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

发布评论

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

评论(2

梦亿 2024-12-18 02:29:51

你的第二个选择是最好的方法。这与您在输入查询时获取推荐搜索结果列表的方式类似。对于您来说,假设您使用 asynctask 来查询数据库,您可以收到由 onProgressUpdate 发出的正确加载消息

Your second option is the best way. Its similar to how you get a list of recommended search results while you type in your query. For you, assuming your using asynctask to query your db you can have a proper loading message signaled by onProgressUpdate

空城仅有旧梦在 2024-12-18 02:29:51

你能对物品进行分类吗?这样您就可以使用微调器来选择类别,并使用 AutoCompleteTextView 来键入和选择项目。

Can you categorize the items? So that you can use use spinner to select the category, and use AutoCompleteTextView to type and select items.

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