logcat的:
06-28 22:21:11.031: E/AndroidRuntime(1282): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(16908298, class android.widget.ListView) with Adapter(class android.widget.ArrayAdapter)]
代码:
protected void onPostExecute(Void v) {
items.add(NewItem);
Collections.sort(items);
adapter.notifyDataSetChanged();
}
问题:我想在哪里更新ListView?
答案 0 :(得分:1)
@Override
protected Void doInBackground(Void... params) {
try {
arrayCountries = objwscountry.CountryCode();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
progressDialog.dismiss();
MyAdapter adapter = new MyAdapter(arrayCountries);
// apply the Adapter:
spinCountry.setAdapter(adapter);
}
看到这段代码非常完美。