start chronometer from dialog box -
i chronometer start when click "ok" button dialogbox... can not. succeed start chronometer when dialog box open. when click "ok" button time has passed...
thanks help... begin code.
my code:
import android.app.activity; import android.app.dialog; import android.os.bundle; import android.os.systemclock; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.chronometer; import android.widget.textview; public class activityone extends activity implements onclicklistener { private chronometer mychronometer; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.timerlayout); mychronometer = (chronometer) findviewbyid(r.id.chronometer); button buttonstart = (button) findviewbyid(r.id.startbutton); button buttonstop = (button) findviewbyid(r.id.pausebutton); button buttonreset = (button) findviewbyid(r.id.resetbutton); buttonstart.setonclicklistener(this); buttonstop.setonclicklistener(this); buttonreset.setonclicklistener(this); final dialog dialog = new dialog(activityone.this, r.style.dialogchrono); dialog.setcontentview(r.layout.dialogchrono); dialog.settitle("titre"); textview txt = (textview) dialog.findviewbyid(r.id.textview4); textview txt1 = (textview) dialog.findviewbyid(r.id.textview1); textview txt2 = (textview) dialog.findviewbyid(r.id.textview2); textview txt3 = (textview) dialog.findviewbyid(r.id.textview3); txt1.settext("texte1"); txt2.settext("texte2"); txt3.settext("texte3"); txt.settext("texte"); button dismissbutton = (button) dialog.findviewbyid(r.id.button); dismissbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { dialog.dismiss(); } }); dialog.show(); } @override public void onclick(view v) { switch (v.getid()) { case r.id.startbutton: mychronometer.start(); break; case r.id.pausebutton: mychronometer.stop(); break; case r.id.resetbutton: mychronometer.setbase(systemclock.elapsedrealtime()); break; } } }
Comments
Post a Comment