Пример #1
0
		public void TimePickDialogShow(EditText edit_inputTime)
		{
			var timepickerlayout = (LinearLayout) activity.LayoutInflater.Inflate (Resource.Layout.commontimepickerlayout, null);
			timePicker = (TimePicker) timepickerlayout.FindViewById<TimePicker>(Resource.Id.timepicker); 
			InitTimePicker (timePicker);
			timePicker.SetIs24HourView(Java.Lang.Boolean.ValueOf(true)); 
			timePicker.SetOnTimeChangedListener(this);  
			var builder = new AlertDialog.Builder (activity).SetView(timepickerlayout);
			builder.SetPositiveButton ("设置", (sender, e) => {
				dialog.Dismiss();	
				edit_inputTime.Text = dateTime;

			});
			builder.SetNegativeButton ("取消", (sender, e) => {
				dialog.Dismiss();	

			});
			dialog= builder.Create ();

			dialog.Show();
			OnTimeChanged (null,0,0);
		}
        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 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;
		}