Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7721671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:58:55+00:00 2026-06-01T03:58:55+00:00

This is not a question, more like sharing with others a problem I encountered

  • 0

This is not a question, more like sharing with others a problem I encountered and how I resolved it.
Basically, I was trying to create a ViewAnimator, who would create additional children in response to user clicks.
To clean up after I have animated the next View in, I put

outAnimation.setAnimationListener(listener);

and in AnimationListener

public void onAnimationEnd(Animation animation) {
    viewAnimator.removeView(out);
}

Now, the problem with above approach is, immediately after onAnimationEnd, it throws a NullPointerException. Basically, it means, ViewAnimator is still using child view that is being animated out to draw. Since I have removed it, there is null there.
I have done my research, and basically, it appears this is a known bug. See: Android Animation is not finished on onAnimationEnd

To resolve this, I have modified layout.

<ViewAnimator
    android:id="@+id/animator"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <FrameLayout
        android:id="@+id/container1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </FrameLayout>

    <FrameLayout
        android:id="@+id/container2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </FrameLayout>
</ViewAnimator>

and onAnimationEnd I can safely call container.removeAllViews(). To animate a new view in, I select the hidden container and

container.addView(newView);
animator.setDisplayedChild(animator.indexOfChild(container));

I will be happy to see your comments and advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:58:56+00:00Added an answer on June 1, 2026 at 3:58 am

    I’ve run into this problem and used the view’s post method to wait until the animation is really done:

          public void onAnimationEnd(Animation animation) {
            //Wait until the container has finished rendering to remove the items.
            view.post(new Runnable() {
              @Override
              public void run() {
                //remove view here
              }
            });
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is not really a programming question, more of an algorithmic one. The problem:
This is not properly a question but something more like a thought I had
I'm not really used to JPA... so this is more like a basic question
Disclaimer : this is not a how to question. I would more like to
This is not an urgent nor important question, seems more like exercise. How to
I'm not talking about making portable code. This is more a question of distribution.
This is really more of a serverfault/IT question, but I am not part of
Ok so this question is not so much about the coding procedure, but more
This is more like a general, brainstroming query rather than a question. So here
This is not a question about a pertinent problem. It's a question by which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.