如何延迟图像视图的更改

时间:2015-07-07 01:22:15

标签: android

您好我试图延迟使用图像视图,让人觉得它们是逐个被取出的。我试过了

Thread.Sleep

CountDownTimer

Runnable/Handler

但他们要么只延迟一次,要么两个图像视图同时改变,要么根本不延迟。为了参考,我尝试做类似

的事情
 private void delaycard(final int Card) {

        newcard(Card); //Delay this before it is called
    }

此时愿意尝试/重试

2 个答案:

答案 0 :(得分:1)

离开我的头顶,尝试这样的事情:

                    Handler h = new Handler();
                    //for the number of images we have
                    for (int i = 0; i < numImages; i++) {

                        //we create a runnable for that action
                        Runnable r = new Runnable() {
                            @Override
                            public void run() {
                                newCard(card);
                            }
                        };

                        //this is the amount of time to delay it by
                        delay = delay + 500;
                        //effectively, we're creating a series of runnables at the same time
                        //but they activate one after the other in .5s intervals
                        h.postDelayed(r, delay);
                    }

答案 1 :(得分:0)

把它放在你的方法

     Handler handler = new Handler();
     handler.postDelayed(new Runnable() {
      @Override
       public void run() {
           newCard(Card);
       }
     }, 100);