如何填充基于第一AutoCompleteTextView选择第二AutoCompleteTextViewAutoCompleteTextView

2023-09-03 22:44:52 作者:-请相信我是人.不是神

我有2 AutoCompleteTextViews 在我的Andr​​oid应用程序,它是从服务器加载数据。第一个负载厂家名称,第二个具有从所选的生产商加载模型

I have 2 AutoCompleteTextViews in my android app which are loading data from the server. The first one loads Manufacturer name and the second one has to load the models from the chosen Manufacturer Name.

我看了一下to更新基于第一个的没有用的,我的价值,但它的,因为我有超过100家制造商nsame第二autocompletetextview。因此,我不希望使用IF statments 100年代,因为它是不好的编程习惯和code会乱码。我的导师建议我使用AJAX(不知道其支持Android和如果不是不知道如何实现它)。

I had a look at to update the second autocompletetextview based on the value of the first one but its of no use to me as I have more than 100 manufacturers nsame. Therefore, I don't want to use 100s of IF statments as it's bad programming practice and code will be messy. My supervisor suggested me to use AJAX (not sure if its supported by android and if it is not don't know how to implement it).

任何建议如何落实这个概念,或者它可以通过AJAX来完成,请告诉我一个教程或和榜样。谢谢!

Any suggestion how to implement that concept or if it can be done by AJAX, please tell me a tutorial or and example. Thanks!

推荐答案

我觉得SQLite是一个关键,解决你的问题。

I think SQLite is a key to solve your problem.

有几种选择:

在您的存储制造商和型号列表中的SQLite。 在您的存储制造商和型号列表中的SQLite。使用更新的HTTP 请求应用程序启动一起与其他数据。 在您的存储制造商和型号列表中的SQLite。使用更新的HTTP 对制造商的要求选择使用时间戳来确定是否 它真正需要的更新。 在厂家更新型号列表中选择使用HTTP请求。​​ Store your manufacturer and model list in SQLite. Store your manufacturer and model list in SQLite. Update using HTTP request on app launch alongside with other data. Store your manufacturer and model list in SQLite. Update using HTTP request on manufacturer select using timestamps to determine whether it really needs update. Update model list on manufacturer select using HTTP request.

的决定

如果您的制造商和型号的列表不会定期更新的网站上,并能与应用程序本身进行更新第一个选项。 在第二和第三个是可行的,如果该列表会定期更新,你有大量的数据需要更新的每个请求。 在第四个是好的,但它高度依赖于服务器的可用性和连接速度,这可能会导致可用性问题。