Showing duration time using stopwatch in android? -
i need toast stopwatch's value
ie.,time taken between start , stop
if click stop button should toast time duration. how this?
here have tried code
chrono_meter.java
public class chrono_meter extends activity { chronometer chr; button btn_stop_travel; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.chronometer_layout); chr = (chronometer)findviewbyid(r.id.chronometer1); chr.start(); btn_stop_travel = (button)findviewbyid(r.id.btn_stop_inspection); btn_stop_travel.setonclicklistener(mstoplistener); } view.onclicklistener mstoplistener = new onclicklistener() { public void onclick(view v) { chr.stop(); } }; }
try
view.onclicklistener mstoplistener = new onclicklistener() { public void onclick(view v) { chr.stop(); toast.maketext(chrono_meter.this, chr.gettext(), toast.length_long).show() ; } };
Comments
Post a Comment