在 Android 中创建复杂搜索表单的最佳方法
我正在尝试创建 Android 应用程序,该应用程序需要许多搜索条件,这些条件最终将形成 SQL 查询并针对数据库运行。
我想将第一组标准呈现为一个三层列表,其中的选择取决于先前的选择,但只有一个最终选择。因此,您可以通过 Car > 导航到 Commodore霍顿>准将。但您可能只想导航到“汽车”(并查看所有汽车的列表)或“霍顿”并查看所有霍顿的列表。
- 汽车
- 霍顿
- 准将
- 贝里纳
- 雷诺
- 梅根
- 霍顿
- 范
- 货车 1
- 货车 1 型 1
- 厢式货车 1 型 2
货车
- 货车 1
等 等等
还有其他标准,例如颜色、地点和自由文本搜索,我想将它们呈现在不同的选项卡上或以某种方式将它们分开。我查看了选项卡式布局,但似乎每个选项卡都使用不同的活动,并且我认为单独的活动相互通信很复杂。
我很感激对此的任何想法,因为我没有时间去发现其他人可能已经经历过的所有缺陷。感谢您的帮助。
非常感谢。 中号
I'm trying to create and Android application which requires a number of search criteria which will eventually form an SQL query and run against a database.
The first set of criteria I'd like to present as a 3-tier list where the choices are dependent on the prior choice but there is only one final choice. So you could navigate to commadore via Car > Holden > Commadore. But you may only want to navigate to Car (and see a list of all cars) or Holden and see a list of all holdens.
- Car
- Holden
- Commadore
- Berina
- Renault
- Megan
- Holden
- van
- van 1
- Van 1 type 1
- Van 1 type 2
- van 1
etc
etc
There will also be other criteria such as colour, place and a free text search, I'd like to present these on a different tab or separate them somehow. I've looked at a tabbed layout but it appears that each tab uses a different activity and I believe that it is complicated for separate activities to talk to each other.
I'd appreciate any thoughts on this as I don't have time to discover all the shortfalls with this that others may have already experienced. Thanks for your help.
Much appreciated.
M
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为每个选项卡的内容创建视图而不是活动。然后,包含 TabHost 的 Activity 将能够使用从每个视图中选择的值。
至于列表和子列表,您可以开始查看 ExpandableListView,但是它只提供了一个两级列表,所以我猜你需要考虑扩展它以允许 n 级。
或者,您可以拥有 n 个 ListView,并在用户做出选择时在它们之间进行转换。
You can create Views instead of activities for the content of each Tab. The Activity which contains your TabHost will then be able to use the values selected from each of the views.
As for the lists, and sublists you can start to look in to the ExpandableListView, however that only provides a two level list, so you would need to look at extending it to allow n-levels I guess.
Alternatively you can have n-number of ListViews and transition between them IF the user makes a selection.