Android, ListView IllegalStateException: “The content of the adapter has changed but ListView did not receive a notification”

What I want to do: run a background thread which calculates ListView contents and update ListView partially, while results are calculated. What I know I have to avoid: I cannot mess with ListAdapter contents from background thread, so I inherited AsyncTask and publish result (add entries to adapter) from onProgressUpdate. My Adapter uses ArrayList of … Read more

How to set selected item of Spinner by value, not by position?

I have a update view, where I need to preselect the value stored in database for a Spinner. I was having in mind something like this, but the Adapter has no indexOf method, so I am stuck. void setSpinner(String value) { int pos = getSpinnerField().getAdapter().indexOf(value); getSpinnerField().setSelection(pos); } 25 Answers 25