c# - How to retain date and time in a variable? -
i have following code:
button schedend = findviewbyid<button>(resource.id.buttonschede); schedend.click += schedend_click; } void schedend_click(object sender, eventargs e) { dialog dialog = new dialog(this); dialog.setcontentview(resource.layout.datetimepickertemplate); dialog.settitle("pick date , time"); timepicker tp = findviewbyid<timepicker>(resource.id.timepicker1); button butadd = findviewbyid<button>(resource.id.buttonadd); //tp.setontimechangedlistener(ontimechangedlistener: retain()); // tp.setis24hourview(new boolean(true)); butadd.click += butadd_click; //tp.setis24hourview(true); dialog.show(); } private void retain() { } void butadd_click(object sender, eventargs e) { edittext edittxt = findviewbyid<edittext>(resource.id.editschstart); edittxt.text = e.tostring(); }
i have custom dialog, date , timepicker
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearlayout1" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <scrollview android:layout_width="fill_parent" android:layout_height="wrap_content"> <linearlayout android:orientation="vertical" android:minwidth="25px" android:minheight="25px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/linearlayout2"> <datepicker android:id="@+id/datepicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <timepicker android:id="@+id/timepicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <button android:text="add" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/buttonadd" /> <button android:text="cancel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/buttoncancel" /> </linearlayout> </scrollview> </linearlayout>
i have tried different methods, no succes, how can retain date , time set,retain in variable,and when click add button dialog,i save them in edittext? new , need help.thx
hopefully i'm understanding question correctly. if mean data user set using timepicker
, can use built in methods such tp.getcurrenthour()
or tp.getcurrentminute()
. there's full list of methods can use on timepicker
in android documentation found here. setting data edittext
, need edittxt.settext(yourvariablehere)
. in particular situation may want consider making timepicker
accessible rest of class such making private instance variable in activity
. way can set edittext
whatever want timepicker
.
Comments
Post a Comment