tags:

views:

83

answers:

2

HI all i hv to images say image1 and image2 i want to display both images on timer, like only one image should be visible at a time, both images are overlapped, mean, image1 is over image2..

so, if i use timer, i can be able to hide and show one image at a time. How to do this. i hope i am clear wid my problem,

.regards

+2  A: 

Put your images in Drawable folder. and create an splash.xml file in drawable folder like this :

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:drawable="@drawable/splash_1" android:duration="200" /> <item android:drawable="@drawable/splash_2" android:duration="200" /> <item android:drawable="@drawable/splash_3" android:duration="200" /> <item android:drawable="@drawable/splash_4" android:duration="200" /> <item android:drawable="@drawable/splash_5" android:duration="200" /> </animation-list>

and in your activity class

setContentView(R.layout.splashscreen);

    final ImageView splashImage = (ImageView) findViewById(R.splash.ImageView);
    splashImage.setBackgroundResource(R.drawable.splash);
    splashAnimation = (AnimationDrawable) splashImage.getBackground();
    splashAnimation.start();
Nishant Shah
Thanks for reply..is it neceesary to name that xml "splash.xml"??secondly, if i change xml name to some xyz amd put this xml to anim folder, than will it work???regards
shishir.bobby
yes you can set any name. but you can not put it in anim folder.
Nishant Shah
but i didnt get 1 point dis is how my oncreate looks like now.setContentView(R.layout.main); setContentView(R.layout.spl); final ImageView splashImage = (ImageView) findViewById(R.id.majicImgView); splashImage.setBackgroundResource(R.drawable.magic_number_white); AnimationDrawable splashAnimation = (AnimationDrawable) splashImage.getBackground(); splashAnimation.start();is it possible to hv 2 setContentView ????
shishir.bobby
You need to set only setContentView(R.layout.main); and you dont have to specify setContentView(R.layout.spl);
Nishant Shah
A: 

Sorry I dont have enough rep to reply on comments

The code does not changes from first image to next.

is any thing wrong withthis code?

final ImageView splashImage = (ImageView) findViewById(R.id.ImageView01);
     splashImage.setBackgroundResource(R.drawable.splash);
     AnimationDrawable splashAnimation = (AnimationDrawable) splashImage.getBackground();
     splashAnimation.start();
Janardhanan.S
if animation does not start, start your animation in onWindowFocusChanged() event
Nishant Shah