layout.setOrientation(LinearLayout.VERTICAL); mChronometer = new Chronometer(this); layout.addView(mChronometer);
c = new Chronometer(true); allMethod1(); c.stop(); System.out.println(c); c = new Chronometer(true); allMethod2(); c.stop(); System.out.println(c + " = " + StringTools.formatDouble((double)baseline / c.getValue() , "0.00") + " times faster than baseline"); c = new Chronometer(true); allMethod3(); c.stop(); System.out.println(c + " = " + StringTools.formatDouble((double)baseline / c.getValue() , "0.00") + " times faster than baseline"); c = new Chronometer(true); allMethod4(); c.stop();
layout.setOrientation(LinearLayout.VERTICAL); mChronometer = new Chronometer(this);
Chronometer chrono = new Chronometer(); chrono.Base = 1000;
public class tests extends Activity{ Button start; Chronometer crono = new Chronometer(); // Instance of Chronometer @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Chronometer test = new Chronometer(this); start = (Button) findViewById(R.id.bStart); start.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { crono.start(); } }); } }
Chronometer test = new Chronometer(this); start = (Button) findViewById(R.id.bStart); start.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // com.example.chrono.Chronometer.start(); test.start(); } });
// create a instance for chronometer Chronometer duration = new Chronometer(this); // starts chronometer inside pause override method duration.setBase(0); duration.start(); // you also need to add onTick listener. duration.setOnChronometerTickListener(new OnChronometerTickListener(){ @Override public void onChronometerTick(Chronometer arg0) { NumberFormat formatter = new DecimalFormat("00"); long countUp = (SystemClock.elapsedRealtime() - arg0.getBase()) / 1000; String asText = formatter.format(countUp / 60) + ":" + formatter.format(countUp % 60); if (is_pause == false) { duration_time = asText; } // once done stop the chronometer inside stop override method and set a flag, check this falg inside OnTickListener and get the duration asText. duration.stop(); is_pause = false;
public class Main implements Observer{ public static void main(String[] args) { Main m = new Main(); Chronometer c = new Chronometer(2014, 7, 4, 13, 46, 21, (byte) 0); c.addObserver(m); c.run(); try { Thread.sleep(200000); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public void update(Observable arg0, Object arg1) { int time = (int)arg1; if(time > 0){ System.out.println("Time left: " + time); } else { System.out.println("The time's over!"); //Update View } } }
private Chronometer chrono = new Chronometer(); private final JLabel message = new JLabel();
LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); mChronometer = new Chronometer(this);
layout.setOrientation(LinearLayout.VERTICAL); mChronometer = new Chronometer(this); layout.addView(mChronometer);
layout.setOrientation(LinearLayout.VERTICAL); mChronometer = new Chronometer(this); layout.addView(mChronometer);
layout.setOrientation(LinearLayout.VERTICAL); mChronometer = new Chronometer(this); layout.addView(mChronometer);