I have a ListView with a custom ArrayAdapter and custom items. These items contain multiple View-element, including a Spinner. This Spinner's ArrayAdapter is set like so:
// Method to set or update the Tags in the Spinner
public void updateTagsSpinner(MyHolder h, Spinner sp){
if(h != null && h.orderedProductItem != null){
// If the given Spinner null, it means we change the OrderedProductItem's Spinner
// Is the given Spinner not null, it means we change the Manage Tag's PopupWindow's Spinner
if(sp == null)
sp = h.spTags;
// We know it's an ArrayAdapter<String> so we just ignore the
// "Unchecked cast from SpinnerAdapter to ArrayAdapter<String>" warning
@SuppressWarnings("unchecked")
ArrayAdapter<String> spAdapt = (ArrayAdapter<String>) sp.getAdapter();
ArrayList<String> tagStrings = Controller.getInstance().getAllTagsWithOrderedProductItem(h.orderedProductItem));
if(tagStrings != null && tagStrings.size() > 0){
if(spAdapt == null){
spAdapt = new ArrayAdapter<String>(ChecklistActivity.this, android.R.layout.simple_spinner_item, tagStrings);
spAdapt.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// ArrayAdapter's setNotifyOnChange is true by default,
// but I set it nonetheless, just in case
spAdapt.setNotifyOnChange(true);
sp.setAdapter(spAdapt);
}
else{
spAdapt.clear();
spAdapt.addAll(tagStrings);
}
}
sp.setSelection(h.orderedProductItem.getSelectedFilter());
}
}
For some reason, every time I scroll down and then up again, my Spinners are completely empty.. And when I click on them I can't even open any Spinners anymore (including the ones that aren't empty) because of a warning:
W/InputEventReceiver(899): Attempted to finish an input event but the input event receiver has already been disposed.