0

I need to be able to access my listview's simpleadapter from an AsyncTask, so I was told I should declare the arrayAdapter as GLOBAL. How can I do that?

Please exemplify with code (that is what I understand best)

Thank you

ZaidRehman
  • 1,631
  • 2
  • 19
  • 30
user1137313
  • 2,390
  • 9
  • 44
  • 91
  • make it static or create in the new class – Akarsh M Apr 11 '14 at 10:17
  • Maybe I was not clear enough. I need to be able to access the adapter from the AsyncTask of a service. The adapter is declared now in an activity. Like this: http://stackoverflow.com/questions/1944656/android-global-variable except I do not need a simple variable but a adapter – user1137313 Apr 11 '14 at 16:35

1 Answers1

0

How any other varible...

class MyActivity extends Activity {
   private ArrayAdapter arrayAdapter;

      protected void onCreate(Bundle save) {
      super.onCreate(save);
      ....
       arrayAdapter = new...
   }

      class myAsyncTask extends AsyncTask<Void, Void, Void> {
           protected Void doInBackground(Void... params) {
           arrayAdapter...
           }
      }
}
MilapTank
  • 9,988
  • 7
  • 38
  • 53
MiguelAngel_LV
  • 1,200
  • 5
  • 16
  • By GLOBAL i mean GLOBAL in the application, not in the activity. So I need to access the adapter declared in activity XXXActivity, from a service on AsyncTask - postExecute – user1137313 Apr 11 '14 at 16:33