Exception occurs when _trd1 starts.
Why it is giving an exception.
I have an imageView on which i have set an Animation.
Same as i did on _imageCard2 they working both fine…
but when i added a new thread it gives an exception after its completion.
public void AnimFunction() {
TranslateAnimation animation2 = new TranslateAnimation(0, -50, 0, 0);
animation2.setDuration(100); // duration in ms
animation2.setRepeatCount(1);
animation2.setRepeatMode(Animation.REVERSE);
animation2.setFillAfter(false);
_imageView.startAnimation(animation2);
_imageView.setImageResource(R.drawable.b1fv);
// Animation
TranslateAnimation animation = new TranslateAnimation(0, 150, 0, 0);
animation.setDuration(400); // duration in ms
animation.setRepeatCount(1);
animation.setRepeatMode(Animation.REVERSE);
animation.setFillAfter(false);
_imageCard2.startAnimation(animation);
Thread _trd1 = new Thread() {
public void run() {
try {
sleep(2000);
_imageCard2.setImageResource(R.drawable.sk);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
_trd1.start();
}
Try: