java - Error in AsyncTask with ImageView -


i'm making project university. try learn asynctask in half hour. hard! make game of "simon" , need colors flash 1 second, 1 after other. i'm not understanding error , how solve...

sorry english, i'm brazilian.

that asynctask class...

package com.example.genius;  import android.os.asynctask; import android.widget.imageview;  public class queue extends asynctask<void, void, imageview> {     protected imageview doinbackground(void... params) {         imageview imagem;         int = gameactivity.numcor;         imagem = gameactivity.cor;         if(i == 0)             imagem.setimageresource(r.drawable.greenlight);         if(i == 1)             imagem.setimageresource(r.drawable.redlight);         if(i == 2)             imagem.setimageresource(r.drawable.yellowlight);         if(i == 3)             imagem.setimageresource(r.drawable.bluelight);         return imagem;     }      protected imageview onpostexecute() {         imageview imagem;         int = gameactivity.numcor;         imagem = gameactivity.cor;         try {             thread.sleep(1000);         }catch(exception e) {}          if(i == 0)             imagem.setimageresource(r.drawable.green);         if(i == 1)             imagem.setimageresource(r.drawable.red);         if(i == 2)             imagem.setimageresource(r.drawable.yellow);         if(i == 3)             imagem.setimageresource(r.drawable.blue);         return imagem;     } } 

and method of gameactivity, call asynctask class...

public void piscarverde() {              numcor = 0;             cor = (imageview)findviewbyid(r.id.green);             queue queue = new queue();             final mediaplayer mediaplayer = mediaplayer.create(this, r.raw.gr);             mediaplayer.start();             queue.execute(); } 

can me this? thank's

your onpostexecute has wrong signature, change:

protected imageview onpostexecute() { 

to

protected void onpostexecute(imageview result) { 

also dont write whats wrong, problem

btw. in java practice add @override annotation when overriding method, compiler output errors in case made error, example:

@override  protected void onpostexecute(imageview result) { 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -