0

ImageButton (blueCondition) の OnTouchListener があります。MotionEvent.ACTION_UP がアクティブになると、別の ImageButton が startFlipping() になります。ImageButton (blueCondition) が再度押される (MotionEvent.ACTION_DOWN) 前に ViewFlipper の最後の画像に到達した場合は、何らかのアクションを実行する必要があります。ImageButton の私のコードは次のとおりです。

blueCondition = (ImageButton)findViewById(R.id.ImageButton04);
flipper1.startFlipping();


blueCondition.setOnTouchListener(new OnTouchListener(){
    public boolean onTouch(View v, MotionEvent event){
        switch(event.getAction()){


        case MotionEvent.ACTION_DOWN:
            flipper1.stopFlipping();
            flipper1.setDisplayedChild(0);
            blueCondition.setImageResource(R.drawable.blue_print_button300);
            break;
        case MotionEvent.ACTION_UP:
            flipper1.startFlipping();
            blueCondition.setImageResource(R.drawable.blue_circle300);
            break;
        }
        return true;
    }
});//endsetOnTouchListener

他の質問と回答から、私は以下のコードで私たちにアニメーションを試みました:

Flipper1.getInAnimation().setAnimationListener(new Animation.AnimationListener() {

    public void onAnimationStart(Animation animation) {}
    public void onAnimationRepeat(Animation animation) {}
    public void onAnimationEnd(Animation animation) {

        int displayedChild = flipper1.getDisplayedChild();
        int childCount = flipper1.getChildCount();

        if (displayedChild == childCount - 1) {
            flipper1.stopFlipping();
        }
    }
});

これはコンパイルされているように見えますが、実行時にクラッシュします。明らかな何かが欠けていると思います..どんな助けでも大歓迎です。

以下は logcat です。

08-23 21:26:08.282: E/AndroidRuntime(32767): 致命的な例外: メイン 08-23 21:26:08.282: E/AndroidRuntime(32767): java.lang.RuntimeException: アクティビティ ComponentInfo{com を開始できません。 andytwistertrials_1/com.andytwistertrials_2.MainActivity}: java.lang.NullPointerException 08-23 21:26:08.282: E/AndroidRuntime(32767): android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 08-23 21: 26:08.282: E/AndroidRuntime(32767): android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122) 08-23 21:26:08.282: E/AndroidRuntime(32767): android.app.ActivityThread.access で$600(ActivityThread.java:140) 08-23 21:26:08.282: E/AndroidRuntime(32767): android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228) 08-23 21:26:08.282: E/AndroidRuntime(32767): android.os.Handler.dispatchMessage(Handler.java:99) 08-23 21:26:08.282: E/AndroidRuntime(32767): android.os.Looper.loop(Looper.java:137) 08-23 21:26:08.282: E/AndroidRuntime(32767): at Android.app.ActivityThread.main(ActivityThread.java:4895) 08-23 21:26:08.282: E/AndroidRuntime(32767): java.lang.reflect.Method.invokeNative(ネイティブ メソッド) 08-23 21:26 で:08.282: E/AndroidRuntime(32767): java.lang.reflect.Method.invoke(Method.java:511) 08-23 21:26:08.282: E/AndroidRuntime(32767): com.android.internal. os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994) 08-23 21:26:08.282: E/AndroidRuntime(32767): com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 08 -23 21:26:08.282: E/AndroidRuntime(32767): dalvik.system.NativeStart.main(Native Method) 08-23 21:26:08.282: E/AndroidRuntime(32767): 原因: java.lang. NullPointerException 08-23 21:26:08.282:E/AndroidRuntime(32767): com.andytwistertrials_2.MainActivity.onCreate(MainActivity.java:60) 08-23 21:26:08.282: E/AndroidRuntime(32767): android.app.Activity.performCreate(Activity.java) :5163) 08-23 21:26:08.282: E/AndroidRuntime(32767): android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 08-23 21:26:08.282: E/AndroidRuntime(32767): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061) 08-23 21:26:08.282: E/AndroidRuntime(32767): ... 11 もっと見る282: E/AndroidRuntime(32767): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061) 08-23 21:26:08.282: E/AndroidRuntime(32767): ... 11 もっと見る282: E/AndroidRuntime(32767): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061) 08-23 21:26:08.282: E/AndroidRuntime(32767): ... 11 もっと見る

4

0 に答える 0