나는 다음과 같은 코드가 있습니다변수에 날짜와 시간을 저장하는 방법은 무엇입니까?
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 and 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();
}
내가 날짜와 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>
나는 다른 방법을 시도,하지만 succes에에, 내가 어떻게 날짜를 유지할 수 있습니다 그리고 시간이 설정되어 변수에 유지하고 대화 상자에서 추가 버튼을 클릭하면 편집 문에 저장됩니다. 나는 이것에 초보적이며 약간의 도움이 필요합니다 .xh
내가 매우 명확하지 않다면, Sry는 편집 텍스트를 설정하기 위해 시간과 날짜 (사용자가 설정)를 모두 가져 가고 싶다. –
'TimePicker'는 단지 시간이라고 생각합니다. 만약 당신이 날짜를위한 인터페이스를 원한다면, 당신은'DatePicker'를 사용할 수 있습니다. 사용자가 'TimePicker'에서 선택한 시간을 검색하는 방법에 대한 내 대답을보다 명확히하는 방법을 모르겠습니다. 내가 너의 질문을 완전히 이해하지 않는 한. – Brian
문제를 해결하기 위해 mydatePIcker.toShortdateString() + ""+ mytime.currentHour + ":"+ mytimepicker.currentMinute를 가져 와서 텍스트 상자에 설정하십시오! 고마워 ! :) –