start animation???

Discussion in 'Application Development' started by Yati, Mar 24, 2010.

  1. Yati

    Yati New Member
    5

    Mar 24, 2010
    4
    0
    5
    Hi,
    I am very new to this forum.

    When i start my project there is an license agreement page where i can acceot and deny and after it goes directly to the animation page.
    I am facing a problem in animation part,when i go to that page my animation does not start immediately,whenever i click something the animation starts,i want it to start immediately without clicking event.
    So please help me with the problem,it would be highly appreciated.

    Thanks
     

    Advertisement
  2. gumatias

    gumatias Member
    5

    Dec 4, 2009
    9
    0
    5
    Java Developer
    I'm not quite sure about what you're trying to accomplish. but maybe placing your code on either onCreate() or onStart() might help.

    -gustavo
     
  3. jarkid

    jarkid New Member
    5

    Dec 30, 2010
    1
    0
    5
    I finally found the answer to this question. I couldn't run the animation directly when I wanted to put the code on OnStart();

    Now I finally found a solution to this.

    You should use a handler to delay the execution in order to run immediately on initial.

    private Handler handler = new Handler();

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.loading);
    ImageView line = (ImageView) findViewById(R.id.loading_line);
    handler.postDelayed(new Runnable()
    {
    public void run()
    {
    AnimationDrawable frameAnimation =
    (AnimationDrawable) line.getBackground();
    frameAnimation.start();
    }
    }, 50);

    }


    This could run fine.
     

Share This Page

Loading...