java - to display one image after the another by using on click method -


i having many images in drawable folder mickey1 , mickey 2 , mickey 3 , mickey 4;i want draw 1 image after 1 form complete mickey mouse . here code

    public class displaymessageactivity extends activity implements onclicklistener  {     button next;     imageview  fullimage;          @override        public void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);          setcontentview(r.layout.activity_display_message);         next=(button)findviewbyid(r.id.button1);         next.setonclicklistener(this);          fullimage = (imageview) findviewbyid(r.id.fullimage);          }      @override     public void onclick(view v) {          int click =1;         if (click == 1) {              fullimage.setimageresource(r.drawable.mickey1);              {                   if(click==2);                  fullimage.setimageresource(r.drawable.mickey2);               }        }     } 

}

you can this

fullimage.settag("1"); 

in oncreate() method.

in onclick(view v) method

string imagenameconst = "mickey"; int imagename = 1; imagename = integer.parseint(fullimage.gettag().tostring())+1;  int id = getresources().getidentifier(imagenameconst + imagename ,"drawable",getpackagename()); fullimage.setimageresource(id); fullimage.settag(imagename); 

this should work if image names mickey1, mickey2, mickey3,....


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -