Ejemplo n.º 1
0
		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			var theme = category.Theme;
			var context = new ContextThemeWrapper (Activity, theme.StyleId);
			var themedInflater = LayoutInflater.From (context);
			return themedInflater.Inflate (Resource.Layout.fragment_quiz, container, false);
		}
		protected override void OnCreate (Android.OS.Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			var mActionBar = ActionBar;
			mActionBar.SetDisplayHomeAsUpEnabled(true);
			mActionBar.SetDisplayShowCustomEnabled(true);
			mActionBar.SetIcon(new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent)));    
			mActionBar.SetDisplayShowTitleEnabled(false);
			LayoutInflater mInflater = LayoutInflater.From(this);
			View mCustomView = mInflater.Inflate(Resource.Layout.samplelist_layout, null);

			selectedGroup= (Group)MainActivity.SelectedIntent.GetSerializableExtra("sample");
			SampleLayout sampleLayouts= new SampleLayout(MainActivity.context,selectedGroup.samples);
			mActionBar.CustomView = mCustomView;
			Sample selectedSample=(Sample)selectedGroup.samples[selectedIndex];

			SetContentView(Resource.Layout.SamplePage);
			ImageView imageButton = (ImageView) mCustomView
				.FindViewById(Resource.Id.imageButton);
			Context wrapper = new ContextThemeWrapper(this, Android.Resource.Style.Theme);
		    ListPopupWindow popupWindow = new ListPopupWindow(wrapper);
			popupWindow.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.listpopup));
				
			imageButton.Click += (object sender, EventArgs e) => {

				popupWindow.Show();
			};
			popupWindow.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {

				Sample subSamples = (Sample) selectedGroup.samples[e.Position];
				selectedIndex = e.Position;
				RefreshSample(subSamples);
				popupWindow.Dismiss();

			};

			RelativeLayout settingButton = (RelativeLayout) mCustomView
				.FindViewById(Resource.Id.settingsParent);
			settingButton.Click += (object sender, EventArgs e) => {

				onProperyWindowClick();
			};
			if(selectedGroup.samples.Count<=1)
			{
				imageButton.Visibility = ViewStates.Invisible;
				
			}
			popupWindow.AnchorView = imageButton;
			popupWindow.Width = measureContentWidth(sampleLayouts);
			popupWindow.SetAdapter(sampleLayouts);
			RefreshSample (selectedSample);
		}
        protected override void OnElementChanged ( ElementChangedEventArgs <CarouselPage> e ) {
            base.OnElementChanged ( e );

            if ( viewPager != null ) {
                if ( viewPager.Adapter != null ) {
                    viewPager.Adapter.Dispose ();
                    viewPager.Adapter = null;
                }
                RemoveView ( viewPager );
                viewPager.SetOnPageChangeListener ( null );
                viewPager.Dispose ();
            }

            if ( indicator != null ) {
                RemoveView ( indicator );
                indicator.SetOnPageChangeListener ( null );
                indicator.Dispose ();
            }

            if ( linearLayout != null ) {
                RemoveView ( linearLayout );
                linearLayout.Dispose ();
            }

            RemoveAllViews ();

            linearLayout = new LinearLayout ( Forms.Context );
            linearLayout.SetGravity ( GravityFlags.Center );
            linearLayout.Orientation = Orientation.Vertical;
            linearLayout.LayoutParameters = new LayoutParams ( LayoutParams.MatchParent , LayoutParams.MatchParent );
            linearLayout.Focusable = true;
            linearLayout.Clickable = true;
            AddView ( linearLayout );

            viewPager = new ViewPager ( Context ) {
                    OffscreenPageLimit = int.MaxValue
            };

            //the following is needed to draw indicator based on the exisitng theme.
            var contextThemeWrapper = new ContextThemeWrapper ( Context , Resource.Style.Theme_PageIndicatorDefaults );
            indicator = new TabCarouselPageIndicator ( contextThemeWrapper , Element );

            linearLayout.AddView ( indicator , new LayoutParams ( LayoutParams.MatchParent , LayoutParams.WrapContent ) );
            linearLayout.AddView ( viewPager , new LinearLayout.LayoutParams ( LayoutParams.MatchParent , 0 , 1.0f ) );

        }
        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 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;
		}
		/**
     * 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;
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.floating_menus_activity);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            FloatingActionMenu menu1 = FindViewById<FloatingActionMenu>(Resource.Id.menu1);
            FloatingActionMenu menu2 = FindViewById<FloatingActionMenu>(Resource.Id.menu2);
            FloatingActionMenu menu3 = FindViewById<FloatingActionMenu>(Resource.Id.menu3);
            FloatingActionMenu menu4 = FindViewById<FloatingActionMenu>(Resource.Id.menu4);
            FloatingActionMenu menuDown = FindViewById<FloatingActionMenu>(Resource.Id.menu_down);
            FloatingActionMenu menuLabelsRight = FindViewById<FloatingActionMenu>(Resource.Id.menu_labels_right);

            FloatingActionButton programFab1 = new FloatingActionButton(this);

            programFab1.ButtonSize = FloatingActionButton.SizeMini;
            programFab1.LabelText = "Programmatically added button";
            programFab1.SetImageResource(Resource.Drawable.ic_edit);
            menu1.AddMenuButton(programFab1);

            ContextThemeWrapper context = new ContextThemeWrapper(this, Resource.Style.MenuButtonsStyle);
            FloatingActionButton programFab2 = new FloatingActionButton(context);
            programFab2.LabelText = "Programmatically added button";
            programFab2.SetImageResource(Resource.Drawable.ic_edit);
            menu2.AddMenuButton(programFab2);

            menus.Add(menuDown);
            menus.Add(menu1);
            menus.Add(menu2);
            menus.Add(menu3);
            menus.Add(menu4);
            menus.Add(menuLabelsRight);

            menuDown.HideMenuButton(false);
            menu1.HideMenuButton(false);
            menu2.HideMenuButton(false);
            menu3.HideMenuButton(false);
            menu4.HideMenuButton(false);
            menuLabelsRight.HideMenuButton(false);


            int delay = 400;
            foreach (var menu in menus)
            {
                mUiHandler.PostDelayed(() => menu.ShowMenuButton(true), delay);
                delay += 150;
            }
                

            menu1.SetOnMenuButtonClickListener(this);
            menu1.SetClosedOnTouchOutside(true);

            menu4.IconAnimated = false;

            menu2.MenuToggle += (object sender, FloatingActionMenu.MenuToggleEventArgs e) => 
                {
                    String text = (e.Opened ? "Menu opened":"Menu closed");
                    Toast.MakeText(this, text, ToastLength.Short).Show();
                };

            fab1 = FindViewById<FloatingActionButton>(Resource.Id.fab1);
            fab2 = FindViewById<FloatingActionButton>(Resource.Id.fab2);
            fab3 = FindViewById<FloatingActionButton>(Resource.Id.fab3);

            fab12 = FindViewById<FloatingActionButton>(Resource.Id.fab12);
            fab22 = FindViewById<FloatingActionButton>(Resource.Id.fab22);
            fab32 = FindViewById<FloatingActionButton>(Resource.Id.fab32);

            fab1.Click += ActionButton_Click;
            fab2.Click += ActionButton_Click;
            fab3.Click += ActionButton_Click;

            fab12.Click += ActionButton_Click;
            fab22.Click += ActionButton_Click;
            fab32.Click += ActionButton_Click;

            fab1.Enabled = false;

            FloatingActionButton fabEdit = FindViewById<FloatingActionButton>(Resource.Id.fab_edit);
            fabEdit.SetShowAnimation(AnimationUtils.LoadAnimation(this, Resource.Animation.scale_up));
            fabEdit.SetHideAnimation(AnimationUtils.LoadAnimation(this, Resource.Animation.scale_down));

            new Handler().PostDelayed(() => fabEdit.Show(true), delay + 150);

            fabEdit.Click += EditButton_Click;

            CreateCustomAnimation();
        }