Tell me how to set the time for the transition to the next Activity. I will explain for what. Assigned animation to a button that lasts 3 seconds. This button translates to another activation. But since the transition takes place immediately, the animation is not visible. Here is the code:

@Override public void onClick(View v){ Animation anim = null; switch (v.getId()){ case R.id.startPlayBtn: anim = AnimationUtils.loadAnimation(this, R.anim.myrotate); Intent intent = new Intent (this, ChooseLvl.class); startActivity(intent); break; default: break; } startPlayBtn.startAnimation(anim); } 

    1 answer 1

    Try this.

     @Override public void onClick(View v) { Animation anim = null; switch (v.getId()) { case R.id.startPlayBtn: Runnable runnable = new Runnable() { @Override public void run() { Intent intent = new Intent(this, ChooseLvl.class); startActivity(intent); } }; anim = AnimationUtils.loadAnimation(this, R.anim.myrotate); new Handler().postDelayed(runnable, 3000); break; default: break; } startPlayBtn.startAnimation(anim); } 
    • Swears at this, here in this line: Intent intent = new Intent (this, ChooseLvl.class); - Michael
    • @Michael: What is the name of the current activation? Indicate CurrentActivity.this - TimurVI 11:53 pm
    • thank you very much, everything works - Michael
    • @Michael: Please. You can vote and / or mark the answer as correct. - TimurVI 0:08