Remove selected item in new selection in spinner

Asked

Viewed 199 times

0

Hello I would like to remove an item already selected in the android spinner.

Example:

ItemA
ItemB -> SELECIONADO
ItemC
ItemD

Since Itemb is selected I wouldn’t want it to appear in the list when I was going to select again in Spinner. Example:

ItemA
ItemC
ItemD

How could I be doing?

I’ve searched Google and found nothing about it, not even in the OS(EN).

Thank you.

  • Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).

  • @Sorack, unfortunately, the answer wasn’t what I was looking for. I ended up not implementing the functionality so as there was no solution of mine nor a proposed solution that worked I did not mark the answer. The only problem in your answer is that it removes and does not re-fix the item when another one is selected.

  • Example: I selected item A, when selecting again will appear item B, C and D if I select any of them the selected item is removed and item A returns the list.

1 answer

0

First get the desired item from Spinner:

int pos = 0;
object item = m_adapterForSpinner.getitem(posicao);

After obtaining the object, remove the item from the adapter of Spinner:

m_adapterForSpinner.remove((CharSequence) item);

Finally determine again the adapter:

spinner.setAdapter(m_adapterForSpinner);
  • But I don’t want him off the list, I just don’t want to show him when selecting another item

  • Something like that? http://stackoverflow.com/questions/3574827/how-to-disable-an-item-in-a-spinner

Browser other questions tagged

You are not signed in. Login or sign up in order to post.