Hide The Selected Item From The Custom Spinner List
I have a Spinner displaying some items via an Adapter. The thing is everytime I click on the spinnerm it shows the list of all items that are selectable by the user. I would like t
Solution 1:
You should create a list of seleted items. So everytime you select an item, you put on this list. After that you compare the two lists: the one with all values, with the one with the selected values and display only the items that aren't already selected. I've already used something like this:
ArrayList<String> allItems = new ArrayList<String>();
ArrayList<String> selectedItems = new ArrayList<String>();
allItems.add("item a");
allItems.add("item b");
allItems.add("item c");
selectedItems.add("item a");
ArrayList<String> auxList = new ArrayList<String>();
//populate an aux list without the selected itemsfor(String itemFromAll: allItems){
for(String selectedItem: selectedItems){
if(!itemFromAll.equals(selectedItem)){
auxList.add(itemFromAll);
}
}
}
//print the new list without the selected itemsfor(String newItem: auxList){
System.out.println(newItem);
}
I hope it helps
Post a Comment for "Hide The Selected Item From The Custom Spinner List"