Skip to content Skip to sidebar Skip to footer

Strange Thread Behavior With Onclicklistener

I am trying to change the background of a button to 'pressed' for 1 second, then change that background back to 'default'. I created one Thread called sleeper that simply sleeps fo

Solution 1:

Please simply use a Handler for that:

Handler h = new Handler();

h.postDelayed(new Runnable() {

    @Override
    public void run() {
        // do your delayed stuff here
    }
}, 1000); // execute the code inside run() after 1000ms

Post a Comment for "Strange Thread Behavior With Onclicklistener"