Tag: listadapter

Android从AsyncTask调用notifyDataSetChanged

我有一个自定义ListAdapter,它在AsyncTask中从Internet获取数据。 数据完全添加到列表中,但是当我尝试执行操作时,应用程序崩溃了…… 我确定这是因为我正在调用notifyDataSetChanged(); 在错误的时间(即在AsyncTask结束之前)。 我现在得到了什么: public class MyListAdapter extends BaseAdapter { private ArrayList mStrings = new ArrayList(); public MyListAdapter() { new RetreiveStringsTask().execute(internet_url); //here I call the notify function **************** this.notifyDataSetChanged(); } class RetreiveStringsTask extends AsyncTask<String, Void, ArrayList> { private Exception exception; @Override protected ArrayList doInBackground(String… urls) { try { URL url= new URL(urls[0]); //return arraylist […]