zoukankan      html  css  js  c++  java
  • Animation(三)

    二、Animation事件监听

    public class AnimationListenerDemoActivity extends Activity {

        private Button add=null;

        private Button del=null;

        private ViewGroup viewGroup=null;

        private ImageView img=null;

        @Override

        public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.main);

            add=(Button)findViewById(R.id.add);

            del=(Button)findViewById(R.id.del);

            viewGroup=(ViewGroup)findViewById(R.id.gvImage);

            img=(ImageView)findViewById(R.id.img);

            

            add.setOnClickListener(new Add());

            del.setOnClickListener(newDel());

        }

        class Add implements OnClickListener{

           public void onClick(View v) {

               // TODO Auto-generated method stub

               AlphaAnimation alpha=new AlphaAnimation(0.0f,1.0f);

               alpha.setDuration(3000);

               alpha.setStartOffset(300);

               ImageView imgView=new ImageView(AnimationListenerDemoActivity.this);

               imgView.setImageResource(R.drawable.icon);

               viewGroup.addView(imgView, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));

               imgView.startAnimation(alpha);

           }

        

        }

        classDel implements OnClickListener{

           public void onClick(View v) {

               // TODO Auto-generated method stub

               AlphaAnimation alpha=new AlphaAnimation(1.0f,0.0f);

               alpha.setDuration(3000);

               alpha.setStartOffset(300);

               alpha.setAnimationListener(new RemoveAnimation());

               img.startAnimation(alpha);

           }

        

        }

        class RemoveAnimation implements AnimationListener{

           public void onAnimationEnd(Animation animation) {

               // TODO Auto-generated method stub

               viewGroup.removeView(img);

           }

            public void onAnimationRepeat(Animation animation) {

               // TODO Auto-generated method stub

               

           }

           public void onAnimationStart(Animation animation) {

               // TODO Auto-generated method stub

               

           }

        

        }

    }

  • 相关阅读:
    学习Spring,看这几本书就够了
    这份书单会告诉你,Java网络编程其实很重要
    心雨(三)【英语】
    成功安装SQL Server实例后 无法找到SQL Server Configuration Manager工具的解决方案
    Windows Cluster失败后,AlwaysOn在残存Server节点上快速恢复DB的详细步骤
    SQL Server 数据库本地备份文件通过OSS工具上阿里云(恢复还原数据库)
    透过systemctl管理mysqld服务
    MongoDB 读偏好设置中增加最大有效延迟时间的参数
    MongoDB 副本集丢失数据的测试
    MySQL 时间类型 DATE、DATETIME和TIMESTAMP
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429509.html
Copyright © 2011-2022 走看看