Android : Make for loop delayed for a certain period of time

on Thursday, October 9, 2014


In this code I want to make the for loop get delayed for 700 ms how can I achieve it. In this code the loop gets completed bez of the delay of 700 ms but I want to make each iteration of for loop delayed for 700ms.One more doubt which I should not use Thread.sleep() on UI thread;



for(int i=0;i<Uirkeys.length;i++){
Handler handler=new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run() {
copyView.get(cnt1).setBackgroundColor(Color.BLACK);
TeaxtToSpeach(map.get(Uirkeys[cnt1]));
cnt1++;
}
},700);
}

0 comments:

Post a Comment