Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.     /**
  2.      * Timer using Threading
  3.      *
  4.      * @param view
  5.      */
  6.     private void startCountUsingThread(final View view) {
  7.         thread = new Thread() {
  8.             @Override
  9.             public void run() {
  10.                 try {
  11.                     while (true) {
  12.                         sleep(1000);
  13.  
  14.                         second++;
  15.                         view.post(new Runnable() {
  16.                             @Override
  17.                             public void run() {
  18.                                 update();
  19.                             }
  20.                         });
  21.                     }
  22.                 } catch (InterruptedException e) {
  23.                 }
  24.             }
  25.         };
  26.         thread.start();
  27.     }
  28.  
  29.  
  30.     /**
  31.      * refresh timer's textfield
  32.      */
  33.     private void update() {
  34.         final TextView textView = (TextView) this.findViewById(R.id.textView_counter);
  35.         textView.setText(this.reformat(this.second));
  36.     }