/** * Create and return the user interface view for this fragment. */ public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState) { int theme = Arguments.GetInt("theme"); int initialHour = Arguments.GetInt("hour"); int initialMinute = Arguments.GetInt("minute"); bool isClientSpecified24HourTime = Arguments.GetBoolean("isClientSpecified24HourTime"); bool is24HourTime = Arguments.GetBoolean("is24HourTime"); // Unless we inflate using a cloned inflater with a Holo theme, // on Lollipop devices the TimePicker will be the new-style // radial TimePicker, which is not what we want. So we will // clone the inflater that we're given but with our specified // theme, then inflate the layout with this new inflater. Context contextThemeWrapper = new ContextThemeWrapper( Activity, theme == SlideDateTimePicker._holoDark ?Android.Resource.Style.ThemeHolo : Android.Resource.Style.ThemeHoloLight); LayoutInflater localInflater = inflater.CloneInContext(contextThemeWrapper); View view = localInflater.Inflate(Resource.Layout.FragmentTimeLayout, container, false); _timePicker = (TimePicker)view.FindViewById(Resource.Id.timePicker); // block keyboard popping up on touch _timePicker.DescendantFocusability = DescendantFocusability.BlockDescendants; _timePicker.SetOnTimeChangedListener(this); // If the client specifies a 24-hour time format, set it on // the TimePicker. if (isClientSpecified24HourTime) { _timePicker.SetIs24HourView((Boolean)is24HourTime); } else { // If the client does not specify a 24-hour time format, use the // device default. _timePicker.SetIs24HourView((Boolean)DateFormat.Is24HourFormat(TargetFragment.Activity)); } _timePicker.CurrentHour = (Integer)initialHour; _timePicker.CurrentMinute = (Integer)initialMinute; // Fix for the bug where a TimePicker's onTimeChanged() is not called when // the user toggles the AM/PM button. Only applies to 4.0.0 and 4.0.3. if ((int)Build.VERSION.SdkInt >= 14 && (int)Build.VERSION.SdkInt <= 15) { FixTimePickerBug18982(); } return(view); }
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState) { int theme = Arguments.GetInt("theme"); int initialYear = Arguments.GetInt("year"); int initialMonth = Arguments.GetInt("month"); int initialDay = Arguments.GetInt("day"); DateTime?minDate = null; DateTime?maxDate = null; if (Arguments.GetLong("minDate", 0) > 0) { minDate = new DateTime(Arguments.GetLong("minDate")); } if (Arguments.GetLong("maxDate", 0) > 0) { maxDate = new DateTime(Arguments.GetLong("maxDate")); } //获取指定主题样式的上下文 Context contextThemeWrapper = new ContextThemeWrapper( Activity, theme == SlideDateTimePicker.HOLO_DARK ? Android.Resource.Style.ThemeHolo : Android.Resource.Style.ThemeHoloLight); LayoutInflater localInflater = inflater.CloneInContext(contextThemeWrapper); View v = localInflater.Inflate(Resource.Layout.Fragment_Date, container, false); mDatePicker = v.FindViewById <CustomDatePicker>(Resource.Id.datePicker); mDatePicker.Init(initialYear, initialMonth, initialDay, this); mDatePicker.DescendantFocusability = DescendantFocusability.BlockDescendants; if (minDate != null) { mDatePicker.MinDate = ConvertDateTimeLong(minDate.Value); } if (maxDate != null) { mDatePicker.MaxDate = ConvertDateTimeLong(maxDate.Value); } return(v); }
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState) { int theme = Arguments.GetInt("theme"); int initialHour = Arguments.GetInt("hour"); int initialMinute = Arguments.GetInt("minute"); bool isClientSpecified24HourTime = Arguments.GetBoolean("isClientSpecified24HourTime"); bool is24HourTime = Arguments.GetBoolean("is24HourTime"); Context contextThemeWrapper = new ContextThemeWrapper( Activity, theme == SlideDateTimePicker.HOLO_DARK ? Android.Resource.Style.ThemeHolo : Android.Resource.Style.ThemeHoloLight); LayoutInflater localInflater = inflater.CloneInContext(contextThemeWrapper); View v = localInflater.Inflate(Resource.Layout.Fragment_Time, container, false); mTimePicker = v.FindViewById <TimePicker> (Resource.Id.timePicker); mTimePicker.DescendantFocusability = DescendantFocusability.BlockDescendants; mTimePicker.SetOnTimeChangedListener(this); if (isClientSpecified24HourTime) { mTimePicker.SetIs24HourView(new Java.Lang.Boolean(is24HourTime)); } else { mTimePicker.SetIs24HourView(new Java.Lang.Boolean(DateFormat.Is24HourFormat(TargetFragment.Activity))); } mTimePicker.CurrentHour = new Java.Lang.Integer(initialHour); mTimePicker.CurrentMinute = new Java.Lang.Integer(initialMinute); if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich && Build.VERSION.SdkInt <= BuildVersionCodes.IceCreamSandwichMr1) { FixTimePickerBug18982(); } return(v); }
/** * Create and return the user interface view for this fragment. */ public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int theme = Arguments.GetInt("theme"); int initialYear = Arguments.GetInt("year"); int initialMonth = Arguments.GetInt("month"); int initialDay = Arguments.GetInt("day"); Date minDate = (Date) Arguments.GetSerializable("minDate"); Date maxDate = (Date) Arguments.GetSerializable("maxDate"); // Unless we inflate using a cloned inflater with a Holo theme, // on Lollipop devices the DatePicker will be the new-style // DatePicker, which is not what we want. So we will // clone the inflater that we're given but with our specified // theme, then inflate the layout with this new inflater. Context contextThemeWrapper = new ContextThemeWrapper(Activity,theme == SlideDateTimePicker._holoDark ?Android.Resource.Style.ThemeHolo : Android.Resource.Style.ThemeHoloLight); LayoutInflater localInflater = inflater.CloneInContext(contextThemeWrapper); View view = localInflater.Inflate(Resource.Layout.FragmentDateLayout, container, false); _datePicker = view.FindViewById<CustomDatePicker>(Resource.Id.datePicker); // block keyboard popping up on touch _datePicker.DescendantFocusability = DescendantFocusability.BlockDescendants; _datePicker.Init (initialYear, initialMonth, initialDay, this); if (minDate != null) _datePicker.MinDate=minDate.Time; if (maxDate != null) _datePicker.MaxDate=maxDate.Time; return view; }