Y
Y
Yaroslav Vorontsov2015-12-20 15:20:36
Java
Yaroslav Vorontsov, 2015-12-20 15:20:36

How to make a piece of java code "sleep" (android programming)?

I have a button that, when clicked, calls the call () function, the contents of the function:

Animation anim = null;
        anim = AnimationUtils.loadAnimation(this, R.anim.myanim);
        Button an;
        an = (Button) findViewById(R.id.an);
        an.startAnimation(anim);
        Intent intent = new Intent(this, Main2Activity.class);
        startActivity(intent);

When you click on the button, you need the animation to go to the end (1 second), and then the transition to another Activity will be performed. How can I make the transition code "sleep" until the animation ends?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
belozerow, 2015-12-20
@ChipoDeil

In the case of animation, it's better to use setAnimationListener.

K
Konstantin Malyarov, 2015-12-20
@Konstantin18ko

wait(1000)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question