variables - Android: How to retrieve values from an AsyncTask? -


i've been researching day trying find out how retrieve values computed in doinbackground async task. no luck @ all.

i'm doing basic httpurlconnection request , parsing xml data webpage using dom. store data in 2 different arrays

///////////inside doinbackground: for(int x=0; x<10; x++) {     username[x] = element.getfirstchild().getnodevalue();     score[x] = anotherelement.getfirstchild().getnodevalue(); } 

now, want output values onto textview.

among many other things, have attempted:

protected void onpostexecute(string result)  {         (int xx = 0; xx<10; xx++)         {             themaintextview.append(username[xx] + " scored " + score[xx] +"\n");         }                } 

nothing have attempted works. recurring error i'm receiving nullpointerexception. doing dramatically incorrect? know of other (even obscure) methods try? ignore loops if helps...i've omitted lot of code. assume want retrieve 2 values...a username , score.

edit: should mention asynctask ends return null;

edit: apparently code not faulty had globally declared button causing null pointer exception. sorry that.

if nullpointerexception stated in question , of onpostexecute() code field themaintextview must null.

you must initialize before starting asynctask - best place in oncreate() activities or oncreateview() fragments.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -