现在的位置: 首页 > 综合 > 正文

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

2013年12月11日 ⁄ 综合 ⁄ 共 637字 ⁄ 字号 评论关闭

  传一个开始位置的坐标,传一个结束位置的坐标,然后依次循环遍历,利用线程休眠达到效果

   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();
        }
       }

抱歉!评论已关闭.