Android Question Removing an index from multiple spinners

Discussion in 'Android Questions' started by Sub7, Apr 6, 2015.

  1. Sub7

    Sub7 Active Member Licensed User

    Hello, i am tryng to figuring out how to remove a specific index from several spinners at once.
    My app have 10 spinner, every spinner have values from 1 to 10:

    spinner1 = 1>10
    spinner2 = 1>10 and so on.
    All the spinners share the same event and i load them inside a customlistview.

    If i select 2 from spinner1 i want that index removed from all other spinners in the activity as it have been already "used" so by expanding spinner2 that number will not be available: 1 (x) 3 4 5 6 7 8 9 10.

    a chunk of code, how can i access the spinner options from here?

    Code:
    Sub spnclick_ItemClick(position As Int, value As Object)
    Dim spin As View = Sender
    Log(spin.Tag&"TAG")
    Log(value&"VALUE")
    Log(position&"POSITION")

    For Each v As View In Activity.GetAllViewsRecursive
    If v Is Spinner Then

      
    For k = 0 To 1
         
    Log(Activity.GetView(k))
         
    Log(v.Tag)
      
    Next
    End If
    Next

    End Sub
    Thanks
     
    Last edited: Apr 6, 2015
  2. Sub7

    Sub7 Active Member Licensed User

    Code:
    Sub spnclick_ItemClick(position As Int, value As Object)
    Dim spin As View = Sender
    Log(spin.Tag&"TAG")
    Log(value&"VALUE")
    Log(position&"POSITION")

    For Each v As View In Activity.GetAllViewsRecursive
    If v Is Spinner Then

    For k = 0 To 1
    Dim sp As Spinner
    'sp = Activity.GetView(k)
    sp = v
    If sp.Tag <> spin.Tag Then
    sp.RemoveAt(position)
    End If
    'Log(sp.Tag)
    Next
    End If
    Next

    End Sub
    Not working yet.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Your code looks correct, except of the For k = 0 to 1 loop which is not required.
     
  4. Sub7

    Sub7 Active Member Licensed User

    Thanks, i removed the unnecessary loop, indeed it was not required.
    It's almost working perfectly but i think i must implement a map of "already updated" spinners because working only with current tag is not okay as when removing an index the value change his position, and it mess up eveything. if i find a solution i'll post here.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice