1

LogCat からのクラッシュ レポートは次のとおりです (私のコードへの参照がないことに注意してください)。

08-27 13:04:36.307    8073-8073/com.example.mysandbox E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.NullPointerException
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2919)
    at android.view.View.getDisplayList(View.java:12833)
    at android.view.View.getDisplayList(View.java:12880)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3057)
    at android.view.View.getDisplayList(View.java:12775)
    at android.view.View.getDisplayList(View.java:12880)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3057)
    at android.view.View.getDisplayList(View.java:12775)
    at android.view.View.getDisplayList(View.java:12880)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3057)
    at android.view.View.getDisplayList(View.java:12775)
    at android.view.View.getDisplayList(View.java:12880)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3057)
    at android.view.View.getDisplayList(View.java:12775)
    at android.view.View.getDisplayList(View.java:12880)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3057)
    at android.view.View.getDisplayList(View.java:12775)
    at android.view.View.getDisplayList(View.java:12880)
    at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1411)
    at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1359)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2367)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2239)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1872)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
    at android.view.Choreographer.doCallbacks(Choreographer.java:562)
    at android.view.Choreographer.doFrame(Choreographer.java:532)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)

そして、ここに私が実行しているアニメーションがあります:

import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.Transformation;
import android.view.animation.TranslateAnimation;
import android.widget.LinearLayout;

public class DeleteAnim extends AnimationSet {

    public View v;
    int initialHeight;

    public DeleteAnim(View view) {
        super(false);
        v = view;
        initialHeight = view.getMeasuredHeight();

        this.setFillEnabled(true);

        TranslateAnimation anim1 = new TranslateAnimation(0F, 500F, 0F, 0F);
        anim1.setInterpolator(new AccelerateInterpolator(1.5F));
        anim1.setDuration(150);
        anim1.setFillAfter(true);

        this.addAnimation(anim1);


        Animation anim2 = new Animation() {

            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                super.applyTransformation(interpolatedTime, t);

                v.getLayoutParams().height = Math.round(initialHeight * interpolatedTime);
                v.requestLayout();
            }
        };

        anim2.setStartOffset(150);
        anim2.setDuration(350);

        this.setFillAfter(true);

        this.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                DeleteAnim anim = (DeleteAnim) animation;
                ((LinearLayout) anim.v.getParent()).removeView(anim.v);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        if (interpolatedTime == 1) {
            v.setVisibility(View.GONE);
        } else {
            v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
            v.requestLayout();
        }
    }
}

誰かが助けてくれるなら、ここで何が問題なのか知りたいです。また、これを API 18 で実行しようとしただけで、アニメーションが開始されるとクラッシュします。

前もって感謝します!

4

1 に答える 1