[SOLVED] Android java.lang.NullPointerException at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2922)

If you are getting this in your Android code:

java.lang.NullPointerException             at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2922)

The reason for this could be that you are trying to do some view changes upon animationEnd. This is not allowed so you need to use this trick:

@Override
public void onAnimationEnd(Animation animation) {
    new Handler().post(new Runnable() {
        public void run() {
            myLayout.removeView(simulateMovingImg);
        }
    });
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s