开发者

Android: Animating a popup menu automatically

开发者 https://www.devze.com 2023-03-09 21:16 出处:网络
How can we set the timerso that after completion of anImage-view animation, a pop up menu should come from bottom automatically with out the user intervention.

How can we set the timer so that after completion of an Image-view animation, a pop up menu should come from bottom automatically with out the user intervention.

Help is always appreciated......!

here is the code

        AnimationDrawable ekgframeAnimation4 =
         (AnimationDrawable) ekgimgview4.getBackground();



         if (ekgframeAnimation4.isRunning()) {
            ekgimgview4.postDelayed(ekgframeAnimation4, 60000);
            ekgframeAnimation4.stop();



            findViewById(R.id.ekgimgview4).postDelayed(new Runnable()
             { 
                 public void run()
                 { 
                     openOptionsMenu(); 
                 }
             }, 60000);


         }

         else {
            ekgframeAnimation4.stop();
           ekgframeAnimation4.start();
           ekgimgview4.postDelayed(ekgframeAnimation4, 60000);

           findViewById(R.id开发者_运维知识库.ekgimgview4).postDelayed(new Runnable()
             { 
                 public void run()
                 { 
                     openOptionsMenu(); 
                 }
             }, 60000);


         }


Do a View.postDelayed call and in the Runnable call openOptionsMenu.

EDIT: if your animation lasts 1000 milliseconds and there is a View with the id R.id.exampleview, then something like this:

findViewById(R.id.exampleview).postDelayed(new Runnable()
{ 
    public void run()
    { 
        openOptionsMenu(); 
    }
}, 1000);

should do it. Let me know if that works out for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消