How to return ArrayList from AsyncTask to another class?

后端 未结 7 607
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 20:01

i want to get Ftp folders list from server using AsyncTask and return folders names ArrayList to main class and update spinner adapter.

In main class i got spinner with

7条回答
  •  佛祖请我去吃肉
    2021-01-21 20:30

    You already made your ArrayList static, make it public as well. and use that by your class name. and populate your ArrayList in onPostExecute(); like

         protected void onPostExecute(ArrayList... result) {
    
        if(YourClassName.directoriesTeacher.size()>0)
         {
           YourClassName.directoriesTeacher.clear();
          }
    
          YourClassName.directoriesTeacher.addAll(result);
    
         }
    

提交回复
热议问题