Updating multiple cascading spinner by AsyncTask - what would be best approach
-
I was looking for suggestion what would be best approach in below scenario: 1. Have 3 spinners ("districts", "city", "shops"). 2. Once user select an item from "districts" spinner, "city" spinner is populated and once city is selected "shops" could be selected. Now I have used a subclass of AsyncTask class to populate district spinner. For populating other spinners "city" and "Shops", is writing separate subclass dedicated to each sinner the only option and update each spinners (which is a View) in each class's onPostExecute() method ? Is there any way to use a single subclass of AyncTask and use that for populating all "cascaded" spinner ? What could be best approach in such scenario.
Thanks, Arindam D Tewary
-
I was looking for suggestion what would be best approach in below scenario: 1. Have 3 spinners ("districts", "city", "shops"). 2. Once user select an item from "districts" spinner, "city" spinner is populated and once city is selected "shops" could be selected. Now I have used a subclass of AsyncTask class to populate district spinner. For populating other spinners "city" and "Shops", is writing separate subclass dedicated to each sinner the only option and update each spinners (which is a View) in each class's onPostExecute() method ? Is there any way to use a single subclass of AyncTask and use that for populating all "cascaded" spinner ? What could be best approach in such scenario.
Thanks, Arindam D Tewary
-
You could use a single subclass and just pass it the id of the spinner and the list of items to populate it.
Yah, Thanks Richard, I could figure out this. I noticed that the first param is an array of argument(varargs) in execute method in AsyncTask and that is something I could use for this purpose. I could just pass an indicator string just to differentiate and used switch-case in onPostExecution method and I could get it going today. I will check with passing view id would help me better.
Thanks, Arindam D Tewary