2012-06-05 91 views
2

如何实现对图像视图触摸这是由帧动画用于帧...我使用这个 如下ontouch上逐帧动画

final AnimationDrawable newtonAnimation = (AnimationDrawable) animation.getBackground(); 

      AnimationStart(newtonAnimation); 

      animation.setOnTouchListener(l); 


public void AnimationStart(final AnimationDrawable newanimation){ 
    Thread timer=new Thread(){ 
     @Override 
     public void run(){ 
          try{ 
            sleep(40); 
           }catch(Exception e){} 
           finally{ 
              Newton_LawsActivity.this.runOnUiThread(new Runnable() { 
               public void run(){ 
               newanimation.start(); 
              }}); 
             } 
          } 
         }; 
    timer.start(); 

} 这是我收到在ontouch事件.......

public boolean onTouch(View v, MotionEvent event) { 
     // TODO Auto-generated method stub 
     Log.w("debug","nullis event"+event+"OR"+gestureDetector.onTouchEvent(event)); 

     return gestureDetector.onTouchEvent(event); 
} 
+0

什么是AnimationStart(牛顿动画)? –

+0

那是方法.. – Ashishsingh

+0

是这个方法做的动画功能吗? –

回答

0

设置ontouch lintener像下面

   animation.setOnTouchListener(new OnTouchListener() 
       { 
        @Override 
        public boolean onTouch(View v, MotionEvent event) 
        { 
         newtonAnimation.stop(); 
         Toast.makeText(FrameAnimationActivity.this, "animation stoped", Toast.LENGTH_LONG).show(); 
         return false; 
        } 
      }); 
+0

你能解释我Toast.makeText(FrameAnimationActivity.this,“动画”,Toast.LENGTH_LONG).show(); – Ashishsingh

+0

吐司只是用于测试触摸事件,你可以把你的代码,而不是吐司http://developer.android.com/guide/topics/ui/notifiers/toasts.html –

+0

FrameAnimationActivity.this是你的活动的上下文 –