0

日志猫:

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?

4

1 回答 1

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);
    }

看到这段代码完美无缺。

于 2012-06-29T05:29:17.650 回答