this is my activity:
public class MainActivity extends Activity implements Animation.AnimationListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
animation1 = AnimationUtils.loadAnimation(this,R.anim.to_middle);
animation2 = AnimationUtils.loadAnimation(this, R.anim.from_middle);
animation2.setAnimationListener(this);
animation1.setAnimationListener(this);
}
@Override
public void onAnimationEnd(Animation animation) {
if (animation == animation1) {
if (isBackOfCardShowing) {
imageview1.setImageResource(R.drawable.dog);
} else {
imageview1.setImageResource(R.drawable.card);
}
imageview1.clearAnimation();
} else {
isBackOfCardShowing=!isBackOfCardShowing;
}
I have animation in my project and implements AnimationListener
in my activity.How i use switch in onAnimationEnd
method? and put this code in first case?
if (animation == animation1) {
if (isBackOfCardShowing) {
imageview1.setImageResource(R.drawable.dog);
} else {
imageview1.setImageResource(R.drawable.card);
}
imageview1.clearAnimation();
} else {
isBackOfCardShowing=!isBackOfCardShowing;
}
I search in internet but not find tutorial about this