0

This is really weired, it plays in Nexus 5, but in all other phones it doesn't work. Please see my code, it definitely doesn't start animation in onCreate.

I can see the first frame.

        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_tiv, container, false);
        final ImageView tv = (ImageView) rootView.findViewById(R.id.touchImageView1);
        tv.setImageDrawable(null);
        tv.postDelayed(new Runnable() {

            @Override
            public void run() {
                playAnimation(tv);
            }
        }, 2000);
        return rootView;
    }
        private void playAnimation(ImageView tv) {
            final AnimationDrawable little = ...;
            tv.setImageDrawable(little);
            little.setOneShot(false);
            tv.post(new Runnable() {

                @Override
                public void run() {
                    little.start();
                }
            });
    }
tactoth
  • 897
  • 1
  • 12
  • 24
  • The 2-second delay seems risky, because you don't really know how soon it will be ready. Have you tried calling playAnimation from onAttach or onResume instead? – Bruce Nov 25 '14 at 08:16
  • Tried. Finally I found the reason is you gonna stop first. – tactoth Nov 25 '14 at 08:25

0 Answers0