简体   繁体   中英

notifyDataSetChanged() doesn't refresh my view

I'm doing this in an AsyncTask, everything working fine but my view is not directly refreshed,

but if i just scroll a bit on my listView the data are refreshed

 ArrayList<Project> listProject =  taskLiteApplication.getListProjectWithStatus(Integer.parseInt(status[0]));


            //set adapter
            projectBaseAdapter.replaceData(listProject);

            //display projects on screen
            projectBaseAdapter.notifyDataSetChanged();

I try to call refreshDrawableState() on my listView and it doesn't work as well and invalidate() too

Any UI updates from an AsyncTask should be done in the onPreExecute and the onPostExecute methods of the AsyncTask class.

So in your case, after your AsyncTask is complete, you want to update the UI. Therefore you should override the onPostExecute method of your AsyncTask , and in that method call projectBaseAdapter.notifyDataSetChanged();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM