android - Alternate image in a imageview of screen -


i have 2 images in drawable folder , desire alternate 2 images in view every x time. try use asynctask don't work , can't found solution.

my xml code

<imageview     android:id="@+id/imageload"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true"     android:layout_centerhorizontal="true"     android:layout_marginbottom="64dp"     android:adjustviewbounds="false"     android:baselinealignbottom="false"     android:contentdescription="@string/imatge"     android:croptopadding="false"     android:fitssystemwindows="false"     android:focusable="false"     android:focusableintouchmode="false"     android:src="@drawable/hdtitol2" /> 

i call class with:

new modifyimage().execute(null,null,null); 

the main class contains de class async code

public class modifyimage extends asynctask<void, void, void> {      imageview img= (imageview)findviewbyid(r.id.imageload);      @override     protected void onpreexecute(){      }     @override     protected void doinbackground(void... params) {         // todo auto-generated method stub         int = 0;         boolean opt = true;         boolean exit = false;         while(!exit){             if(i == 1000){                 = 0;                 if(!opt){                     img.setimageresource(r.drawable.blackhdtitol2);                     opt =true;                 }else{                     opt = false;                     img.setimageresource(r.drawable.hdtitol2);                 }             }             i++;         }         return null;     }      @override     protected void onpostexecute(void i){      }  } 

do this,

new handler().postdelayed(new runnable() {     @override     public void run() {         integer tag = (integer) img.gettag();         if(tag == r.drawable.blackhdtitol2){                 img.setimageresource(r.drawable.blackhdtitol2);                 img.settag(r.drawable.blackhdtitol2);             }else{                 img.setimageresource(r.drawable.hdtitol2);                 img.settag(r.drawable.hdtitol2);             }     } }, 60*1000); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -