自定义对话框日期选择器24小时视图错误



我有以下问题,我有一个自定义对话框,代码在这里:

 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'   

我是这方面的初学者,所以我真的希望得到一些帮助!太多了!

尝试将tp.Is24HourView(true);替换为tp.SetIs24HourView((Java.Lang.Boolean)(true));

最新更新