Thread sleep, does not do
I have problem with Thread in Java. I want to make when the button (bt1)
is clicked to set Background to picture, then wait for 5 seconds and the
set Background of the same button to pic. The problem is that the first
picture has never been set. The program just wait 5 seconds and set
picture2. Here is the code.
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bt1.setBackgroundResource(R.drawable.picture); try { Thread.sleep(5000); }
catch( InterruptedException e ) { e.printStackTrace(); }
bt1.setBackgroundResource(R.drawable.pic); } });
}
Please help. Thanks
No comments:
Post a Comment