キーボードナビゲーションを使用してのみ日付を選択します。タブと矢印キーを使用して月と年をナビゲートすることはできましたが、キーボードを使用して日付を選択することはできません。
あなたはそれを達成するための活動のOnkeyUp
イベントを使用することができます。
public class MainActivity : Activity
{
DatePicker mDatePicker;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
mDatePicker = FindViewById<DatePicker>(Resource.Id.mDatePicker);
}
public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent e)
{
//when user press c, the date of the DatePicker will be updated
if (keyCode == Keycode.C)
{
mDatePicker.UpdateDate(mDatePicker.Year, mDatePicker.Month, mDatePicker.DayOfMonth + 1);
}
return true;
}
}
Main.axml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<DatePicker
android:id="@+id/mDatePicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>