Animation don't work with a changing of the ImageView Drawable

JG_

New Member
Hi have a problem with Animation, actually i want to fade my ImageView while it's changing it resource.It's not working, i can change the resource but without any animation.\[code\]private void checkX() { // TODO Auto-generated method stub switch (x) { case (1): { startingAnimation(); xImg.setImageResource(R.drawable.test_uno); endingAnimation(); break; } case (2): { startingAnimation(); xImg.setImageResource(R.drawable.test_due); endingAnimation(); break; } case (3): { startingAnimation(); xImg.setImageResource(R.drawable.test_tre); endingAnimation(); break; } case (4): { startingAnimation(); xImg.setImageResource(R.drawable.test_quattro); endingAnimation(); break; } case (5): { x = 1; checkX(); break; } case (0): { x = 4; checkX(); break; } }}private void endingAnimation() { // TODO Auto-generated method stub ObjectAnimator animation2 = ObjectAnimator.ofFloat(xImg, "alpha", 255); animation2.setDuration(1000); animation2.start();}private void startingAnimation() { // TODO Auto-generated method stub ObjectAnimator animation = ObjectAnimator.ofFloat(xImg, "alpha", 0); animation.setDuration(1000); animation.start();}\[/code\]checkX is called each time i press a button(that add or subtract 1 to X).How i can make both animations and ImageView resource change?
 
Back
Top