我有以下问题,我有一个自定义对话框,代码在这里:
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("Choose Date and Time");
TimePicker tp = FindViewById<TimePicker>(Resource.Id.timePicker1);
tp.Is24HourView(true);
dialog.Show();
}
tp.Is24HourView(true);
给我这个错误,方法Is24HourView
没有重载,需要1个参数。在对话框中,我有datepicker
和timepicker
,这里是axml:
<?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">
<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" />
</LinearLayout>
如何设置timePicker以显示24小时格式,它目前显示12小时格式。
我也试过tp.SetIs24HourView(true);
但我得到以下错误:
Error 1 The best overloaded method match for 'Android.Widget.TimePicker.SetIs24HourView(Java.Lang.Boolean)' has some invalid arguments
and
Error 2 Argument 1: cannot convert from 'bool' to 'Java.Lang.Boolean'
我是初学者,所以我真的会帮助你!很多!
答案 0 :(得分:0)
尝试将tp.Is24HourView(true);
替换为tp.SetIs24HourView((Java.Lang.Boolean)(true));