星期二, 7月 09, 2013

Android hide a view after a few seconds


Spawn a separate thread that sleeps for 3 seconds then call runOnUiThread to hide the view.
Thread thread = new Thread() {
   @Override
   public void run() {
       try {
           Thread.sleep(3000);
       } catch (InterruptedException e) {
       }

       runOnUiThread(new Runnable() {
           @Override
           public void run() {
               // Do some stuff
           }
       });
   }
};

沒有留言: