Android spinner drop down with non selected items only - android

How to show spinner drop down with only the items which is not currently selected like below images
Drop down list when spinner with FOLLOWING as current item is clicked
Drop down list when spinner with NEW as current item is clicked

There is no default setup for that usecase. You need the change the Data-Set of the SpinnerAdapter (Model) or change the Adapter used by your Spinner in the onItemSelected method and save the selected Item in a sparate variable. A Spinner always displays alle Items in from the Spinner Adapter. There is also not the option to add an emty cell.

Related

how to add item hidden in list to add in spinner when items in spinner get of json

how to add item hidden in list to add in spinner when items in spinner get of json i used Spinner and tried AppCompatSpinner and android:prompt="#string/filter"
but all this not working
See the attached images

select item in getView method adapter spinner

i have spinner that i create with my custom adapter and i want to select specify item in load spinner and do not use setSelection method for select specify item because i use AsyncTask for load data to spinner.
write this code in adapter :
spinner.setSelection(myposition);
this method work but when click on spinner and chose an item, dropDown not hidden.
my question is how can i select item when i creating the items spinner.
i means how can i select item in the getView method in adapter?
please help me.
whe loading data in asyncTask (e.g for loop to fill arrayList) you can note the position you need to select and after adding all the data to adapter call the select method on spinner within same ayncTask (postExecute).
And why don't your drop down hiding are you overriding the click function of spinner ?

Selected option shouldn't appear in spinner dropdown list

I have a Spinner that is used to populate some choices. My Spinner acts as a filter to the ListView below it.
The Spinner looks something like this:
****Option 2**** (selected)
****Option 1****
****Option 2****
****Option 3****
****Option 4****
Is there a way that i can hide the selected item from the dropdown list, like in this case Option 2 which is selected shouldn't appear in the dropdown list
Android Spinner not providing any built in implementation which satisfy your requirement.
You need to modify the data set of your Spinner Adapter when user select any item.
Save the selected Item in separate variable and remove it from data set of your Spinner adapter. When user select any other item, you need to add already selected item to data set, save the newly selected item in global variable and remove it from data set of Spinner adapter.

Dynamically added spinner with same list items

I am developing a android application in which has a spinner and an Add button. On a click of add button, the spinner gets added in a container layout. The spinner has list of items. I want to display the same list inside a 2nd spinner without the item which has been selected in the first spinner and every time on the click of add button new spinner should get added with the list without the items which are already selected in previous spinners.
I know how to dynamically add a spinner, my problem is that I am not able to modify a same list and and display in new spinner instance.

how to delete the particular selected item from the list of items in spinner

I followed http://www.designerandroid.com/?p=8 this one to add the values in the spinner.In it while we select the "clear spinner items" the whole events are will be delete. But i need to the selected particular item only want to delete.Any one can help me.. The sample code will help to me lot.
If you want to remove the selected item in the spinner:
adapter.remove((String)spinner.getSelectedItem());
adapter.notifyDataSetChanged();
where "adapter" is the adapter set to the spinner, it's as simple as that. :)
if adapter is out of scope you can get the adapter from the spinner, cast properly and remove the item:
((List<String>) spinner.getAdapter()).remove((String)spinner.getSelectedItem());
((List<String>) spinner.getAdapter()).notifyDataSetChanged();
To delete particular item from spinner you have to remove it from arrayadapter which you are using for filling it.
So first get the position of item you are wanting to delete.
Then get the object from arrayadapter from its position by method.
int pos = 0;
object t= m_adapterForSpinner.getitem(pos); // where m_arrayadapter is array adapter using for filling spinner
And then remove it from spinner by using following code:
m_adapterForSpinner.remove((CharSequence) t);
Then fill your spinner again with arrayadapter.

Categories

Resources