here there
here there

Reputation: 1

Android Spinner. How do I delete an item from the spinner?

I'm creating a flight app. I have 2 spinners: spinOrigin and spinDestination; I also have m_array for the items I want to put on the spinners: "Place1","Place2", and "Place3".

What I want to achieve is if I chose "Place1" from spinner spinOrigin, "Place1" should be deleted so that only "Place2" and "Place3" will be left to choose from from spinner spinDestination.

Upvotes: 0

Views: 2484

Answers (2)

devmiles.com
devmiles.com

Reputation: 10014

  1. Remove the element from your ArrayAdapter<String>
  2. Call notifyDataSetChanged() on your adapter, it will update the spinner automatically.

Upvotes: 1

Rajkiran
Rajkiran

Reputation: 16191

Simply remove that element from your ArrayAdapter<String> that you apply to your Spinner and apply that adapter again to your Spinner to refresh it.

Upvotes: 0

Related Questions