Android:从 SQLite 获取数据并按与手机的距离以列表视图顺序显示的最佳实践

发布于 2024-10-08 23:47:52 字数 436 浏览 0 评论 0原文

我在具有纬度和经度的地方有一个 SQL Lite 数据库,我想从 SQL Lite 中获取数据,并以某种方式(在 SQL 问题中或在自定义适配器中)或者最佳实践是整理出其中的所有地方距离手机 5 英里的位置并显示在 ListView 中。

我有一个想法,但如果有人有更好的想法,我会更受伤。

我可以从 SQL Lite 中取出所有数据,并将其放入带有自定义适配器的 ListView 中,该适配器从 LocationManager 获取手机位置,然后以某种方式删除 distanceTo 超过 5 英里的项目,我希望通过自定义适配器我可以也在排序,但这里还没有所有的部分。

我认为我的解决方案可行,但是有更好的解决方案吗?

我还可以说它大约有 400 个位置,所以使用自定义适配器来做到这一点也许没什么大不了的。

所有解决方案都很好,我对 Android 比较陌生,但正在学习。

I have a SQL Lite database on places with a latitude and longitude and I want to get the data from SQL Lite and some way, either in the SQL question or in a custom adapter or what the best practice is sort out all places that are in a 5 miles distance from the phone location and show in a ListView.

I have one idea I figure out but wounder if someone has a better idea.

I can get out all data from SQL Lite and put it in a ListView with a custom adapter that gets the phone location from a LocationManager and then somehow remove the items that has a distanceTo longer then 5 miles and I hope with the custom adapter I can sorting also but don't have all pieces here yet.

And I think my solution going to work but is there any better solution?

I can also say that its around 400 places so maybe not a big deal to do this with custom adapter.

All solutions is good, I am relative new on Android but learning.

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

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

发布评论

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

评论(1

云仙小弟 2024-10-15 23:47:52

考虑到 SQLite 数据库没有空间功能,我认为你的方法很好。然后,您的自定义适配器应该能够将数据限制为距手机当前位置指定距离内的数据。

I think your approach is good considering that the SQLite database has no spatial functionality. Your custom adapter should then be able to limit the data to those within a specified distance from the phone's current location.

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