如何让10个button 依次换图片,形成连续效果

来源:互联网 发布:小资生活知乎 编辑:程序博客网 时间:2024/05/16 17:52
  传一个开始位置的坐标,传一个结束位置的坐标,然后依次循环遍历,利用线程休眠达到效果

   for (j = frommo; j < tomo; j++) {
        runOnUiThread(new Runnable() {

         public void run() {
          btns[j + 1]
            .setBackgroundResource(R.anim.peopleanim);
          animationDrawable = (AnimationDrawable) btns[j + 1]
            .getBackground();
          btns[j + 1].setAlpha(0);
          animationDrawable.setOneShot(true);
          animationDrawable.stop();
          animationDrawable.start();
          // service.start();
          // service.stop();

         }
        });
        try {
         Thread.sleep(1000);
        } catch (InterruptedException e) {
         e.printStackTrace();
        }
       }

原创粉丝点击