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.
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).
Any suggestion how to implement that concept or if it can be done by AJAX, please tell me a tutorial or and example. Thanks!
I think SQLite is a key to solve your problem.
There are several options:
- 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.
Decision
- First option if your list of manufacturer and model is not regularly updated on the website and could be updated with the app itself.
- Second and third are viable if the list is updated regularly and you have huge amounts of data to be updated on each request.
- Fourth one is ok, but it highly relies on server availability and connection speed, which could cause usability issues.
来源:https://stackoverflow.com/questions/24644959/how-to-populate-second-autocompletetextview-based-on-the-first-autocompletetextv