Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 自动翻转时最后一个子对象的ViewFlipper侦听器_Android - Fatal编程技术网

Android 自动翻转时最后一个子对象的ViewFlipper侦听器

Android 自动翻转时最后一个子对象的ViewFlipper侦听器,android,Android,我有一个ImageButton(blueCondition)的OnTouchListener。 当MotionEvent.ACTION\u UP被激活时,另一个ImageButton将启动Lipping()。如果在再次按下ImageButton(blueCondition)(MotionEvent.ACTION_DOWN)之前到达ViewFlipper的最后一个图像,则我需要采取一些措施。 我的ImageButton代码是: blueCondition = (ImageButton)findVi

我有一个ImageButton(blueCondition)的OnTouchListener。 当MotionEvent.ACTION\u UP被激活时,另一个ImageButton将启动Lipping()。如果在再次按下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(新建Animation.AnimationListener()){

这似乎是编译,但运行时崩溃。我想我错过了一些明显的东西。任何帮助都将不胜感激

以下是日志:

08-2321:26:08.282:E/AndroidRuntime(32767):致命异常:主 08-23 21:26:08.282:E/AndroidRuntime(32767):java.lang.RuntimeException:无法启动活动组件信息{com.andytwistertrials_1/com.andytwistertrials_2.MainActivity}:java.lang.NullPointerException 08-2321:26:08.282:E/AndroidRuntime(32767):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)上 08-2321:26:08.282:E/AndroidRuntime(32767):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122) 08-2321:26:08.282:E/AndroidRuntime(32767):在android.app.ActivityThread.access$600(ActivityThread.java:140) 08-2321:26:08.282:E/AndroidRuntime(32767):在android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228) 08-2321:26:08.282:E/AndroidRuntime(32767):在android.os.Handler.dispatchMessage(Handler.java:99)上 08-2321:26:08.282:E/AndroidRuntime(32767):在android.os.Looper.loop(Looper.java:137)上 08-2321:26:08.282:E/AndroidRuntime(32767):位于android.app.ActivityThread.main(ActivityThread.java:4895) 08-2321:26:08.282:E/AndroidRuntime(32767):位于java.lang.reflect.Method.Invokenactive(本机方法) 08-2321:26:08.282:E/AndroidRuntime(32767):位于java.lang.reflect.Method.invoke(Method.java:511) 08-2321:26:08.282:E/AndroidRuntime(32767):在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994) 08-2321:26:08.282:E/AndroidRuntime(32767):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 08-2321:26:08.282:E/AndroidRuntime(32767):在dalvik.system.NativeStart.main(本机方法) 08-2321:26:08.282:E/AndroidRuntime(32767):由以下原因引起:java.lang.NullPointerException 08-2321:26:08.282:E/AndroidRuntime(32767):在com.andytwistertrials_2.MainActivity.onCreate(MainActivity.java:60) 08-2321:26:08.282:E/AndroidRuntime(32767):在android.app.Activity.performCreate(Activity.java:5163)上 08-2321:26:08.282:E/AndroidRuntime(32767):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)上 08-2321:26:08.282:E/AndroidRuntime(32767):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)上
08-23 21:26:08.282:E/AndroidRuntime(32767):…11更多

请发布来自logCatHave的崩溃消息在原始问题中添加了来自logCat的崩溃消息。
    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();
        }
    }
});