Android动画:在切换情况1中不起作用

时间:2019-01-24 06:58:42

标签: android animation switch-statement android-pageradapter

我正在尝试在ViewPager PagerAdapter中的图像上显示弹出动画,它在Switch情况0和情况2下可以正常工作,但在情况1下不起作用,我从过去两天开始致力于此问题,无法理解在哪里是错误

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View view = layoutInflater.inflate(layouts[position], container, false);

        switch (position) {
            case 0:
                view = layoutInflater.inflate(R.layout.get_started_slide_one,
                        (ViewGroup) null, false);
                ((ImageView) view.findViewById(R.id.bubble_msg_one)).startAnimation(expandIn);
                break;
            case 1:
                view = layoutInflater.inflate(R.layout.get_started_slide_two,
                        (ViewGroup) null, false);
                ((ImageView) view.findViewById(R.id.bubble_msg_two)).startAnimation(expandIn);
                break;
            case 2:
                view = layoutInflater.inflate(R.layout.get_started_slide_three,
                        (ViewGroup) null, false);
                ((ImageView) view.findViewById(R.id.bubble_msg_three)).startAnimation(expandIn);
                break;
            default:
                break;
        }
        container.addView(view);
        return view;
    }

0 个答案:

没有答案