动画侦听使用了AnimationListener接口,需要实现三个方法onAnimationStart()、onAnimationRepeat()、onAnimationEnd()

 

代码:

实现Button的动画侦听

 1         findViewById(R.id.btnAnimation).setOnClickListener(new OnClickListener() {
 2             
 3             @Override
 4             public void onClick(View v) {
 5                 // TODO Auto-generated method stub
 6                 Animation a=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.anim);
 7                 a.setAnimationListener(new AnimationListener() {
 8                     
 9                     @Override
10                     public void onAnimationStart(Animation animation) {
11                         // TODO Auto-generated method stub
12                         
13                     }
14                     
15                     @Override
16                     public void onAnimationRepeat(Animation animation) {
17                         // TODO Auto-generated method stub
18                         
19                     }
20                     
21                     @Override
22                     public void onAnimationEnd(Animation animation) {
23                         // TODO Auto-generated method stub
24                         Toast.makeText(getApplicationContext(), "Animation End", Toast.LENGTH_SHORT).show();
25                     }
26                 });
27                 v.startAnimation(a);
28             }
29         });

 

相关文章:

  • 2021-10-01
  • 2022-01-17
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2021-09-10
  • 2021-11-15
猜你喜欢
  • 2021-06-14
  • 2021-08-23
  • 2021-08-22
  • 2021-12-25
  • 2022-12-23
  • 2021-11-03
  • 2021-09-22
相关资源
相似解决方案