NullPointerException that doesn't point to any line in my code

后端 未结 5 1968
無奈伤痛
無奈伤痛 2020-12-04 19:22

I am working on a game where the player can drag and drop things around the screen. I\'ve got a private method which allows me to simulate a drag/drop event for any of the i

5条回答
  •  囚心锁ツ
    2020-12-04 20:06

    Android will make an exception when you change the view hierarchy in animationEnd.

    All you have to do is to postpone your call like this :

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

提交回复
热议问题