Android Question Removing an index from multiple spinners

Sub7

Active Member
Licensed User
Longtime 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?

B4X:
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:

Sub7

Active Member
Licensed User
Longtime User
B4X:
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.
 
Upvote 0

Sub7

Active Member
Licensed User
Longtime 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.
 
Upvote 0
Top