jramirez
jramirez

Reputation: 484

Wait for animation end

I've an activity that loads the resources and shows the message "Please wait, loading", and when all resources are loader, the textview changes to "Ready" and change the views of the activity. The problem is that I want to wait for the animation end, but the views are removed even before they start. How can I wait for that?

        tview1.startAnimation(desvanecer); tview2.startAnimation(desvanecer);

        tview1.setText(R.string.ready); 
        tview2.setText(R.string.launcher_continue);

        tview1.startAnimation(aparecer);
        tview2.startAnimation(aparecer);

        layout = (RelativeLayout) findViewById(R.id.launcher_layout);

        screen = new Screen(context);

        thread = new Thread(screen);

        layout.removeAllViews();

        layout.addView(screen);

        thread.start();

Upvotes: 0

Views: 1326

Answers (2)

pfairbairn
pfairbairn

Reputation: 451

You can perform your removals at the end of the animation by using an animation listener and doing them onAnimationEnd

desvanecer.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                 //REMOVAL OR OTHER CODE HERE
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

Upvotes: 1

jboi
jboi

Reputation: 11892

What you need is an AnimationListener and implement the onAnimationEnd method. But have a look at my comment and the doubts I have about your code.

Upvotes: 0

Related Questions