Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Updating multiple cascading spinner by AsyncTask - what would be best approach

Updating multiple cascading spinner by AsyncTask - what would be best approach

Scheduled Pinned Locked Moved Android
questionannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arindam Tewary
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • A Arindam 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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You could use a single subclass and just pass it the id of the spinner and the list of items to populate it.

      A 1 Reply Last reply
      0
      • L Lost User

        You could use a single subclass and just pass it the id of the spinner and the list of items to populate it.

        A Offline
        A Offline
        Arindam Tewary
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups