I have been searching for a while now but can’t find a working solution for my android code. Well at least one I am able to implement.
I have an activity (StartActivity) with a few animations. Then I have an onTouchEvent. This works fine to prompt a few more animations however after this I want to open a new Activity.
Here is my code:
public class StartActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
RunAnimations(R.anim.translate1, R.anim.translate2);
}
public void RunAnimations(int t1, int t2) {
Animation a = AnimationUtils.loadAnimation(this, t1);
a.reset();
Animation b = AnimationUtils.loadAnimation(this, t2);
b.reset();
ImageView drop = (ImageView) findViewById(R.id.drop);
ImageView iflush = (ImageView) findViewById(R.id.iflush);
drop.clearAnimation();
iflush.clearAnimation();
drop.startAnimation(a);
iflush.startAnimation(b);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
RunAnimations(R.anim.translate3, R.anim.translate4);
}
return true;
}
}
In the onTouchEvent, after calling RunAnimations, I want to start a new activity (TipActivity). That is all.
Add another activity to you
AndroidManifestfile like so:And then you could do something like (after calling
RunAnimations()) :Hope that helps.