Unable to modify ArrayAdapter in ListView: UnsupportedOperationException
Solution 1:
I tried it out, myself...Found it didn't work. So i check out the source code of ArrayAdapter and found out the problem. The ArrayAdapter, on being initialized by an array, converts the array into a AbstractList (List) which cannot be modified.
Solution
Use an ArrayList<String>
instead using an array while initializing the ArrayAdapter.
String[] array = {"a","b","c","d","e","f","g"};
ArrayList<String> lst = new ArrayList<String>(Arrays.asList(array));
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, lst);
Cheers!