I want to give a time difference of 1 second between the consecutive statement i know it multithreading is used for giving time difference.can any one please help how to create a time difference in executing two statements .
Thanks a lot!
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
public class HelloActivity extends Activity {
Canvas1[] can;
Integer in[]={R.id.can1,R.id.can2,R.id.can3,R.id.can4,R.id.can5,
R.id.can6,R.id.can7,R.id.can8,R.id.can9,R.id.can10,
R.id.can11,R.id.can12,R.id.can13,R.id.can14,R.id.can15,R.id.can16};
/** Called when the activity is first created. */
Button start,stop;
@Over开发者_C百科ride
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
start=(Button)findViewById(R.id.btn1);
stop=(Button)findViewById(R.id.btn2);
can=new Canvas1[16];
for(int i=0;i<in.length;i++)
can[i]=(Canvas1)findViewById(in[i]);
for(int i=0;i<in.length;i++)
can[i].set(0);
//i want to make a time difference of 1 sec before control goes to the for loop
}
}
any_view_in_your_activity.postDelayed(new Runnable(){public void run(){
// Any code you write here will be run on UI thread after 1 second
}}, 1000);
精彩评论