当前位置: 首页>>代码示例>>C#>>正文


C# Android.CloneInContext方法代码示例

本文整理汇总了C#中Android.CloneInContext方法的典型用法代码示例。如果您正苦于以下问题:C# Android.CloneInContext方法的具体用法?C# Android.CloneInContext怎么用?C# Android.CloneInContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android的用法示例。


在下文中一共展示了Android.CloneInContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreateView

        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;
        }
开发者ID:meirongIn83,项目名称:SlideDatetimePickerCSharp,代码行数:41,代码来源:DateFragment.cs

示例2: OnCreateView

        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;
        }
开发者ID:meirongIn83,项目名称:SlideDatetimePickerCSharp,代码行数:36,代码来源:TimeFragment.cs

示例3: OnCreateView

		/**
     * 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;
		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:54,代码来源:TimeFragment.cs


注:本文中的Android.CloneInContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。