コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            var fragments = new Android.Support.V4.App.Fragment[]
            {
                new TimeFragment(),
                new StopwatchFragment(),
                new AboutFragment()
            };

            // TODO #5
            var titles = CharSequence.ArrayFromStringArray(new[] { "Time", "Stopwatch", "About" });

            var adapter = new ClockAdapter(base.SupportFragmentManager, fragments, titles);

            var viewPager = FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.viewPager);

            viewPager.Adapter = adapter;

            var tabLayout = FindViewById <Android.Support.Design.Widget.TabLayout>(Resource.Id.tabLayout);

            tabLayout.SetupWithViewPager(viewPager);

            // TODO #6
            tabLayout.GetTabAt(0).SetIcon(Resource.Drawable.ic_access_time_white_24dp);
            tabLayout.GetTabAt(1).SetIcon(Resource.Drawable.ic_timer_white_24dp);
            tabLayout.GetTabAt(2).SetIcon(Resource.Drawable.ic_info_outline_white_24dp);
        }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            var fragments = new Android.Support.V4.App.Fragment[]
            {
                new TimeFragment(),
                new StopwatchFragment(),
                new AboutFragment()
            };

            var titles = CharSequence.ArrayFromStringArray(new []
            {
                "Time",
                "Stopwatch",
                "About"
            });

            viewPager         = FindViewById <ViewPager>(Resource.Id.viewPager);
            adapter           = new ClockAdapter(base.SupportFragmentManager, fragments, titles);
            viewPager.Adapter = adapter;

            //
            // TODO: Assign the ClockAdapter to the ViewPager's Adapter property
            //
        }
コード例 #3
0
ファイル: MainActivity.cs プロジェクト: scotch83/AND205
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            var fragments = new Android.Support.V4.App.Fragment[]
            {
                new TimeFragment(),
                new StopwatchFragment(),
                new AboutFragment()
            };

            var adapter = new ClockAdapter(base.SupportFragmentManager, fragments);

            var viewPager = FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.viewPager);

            viewPager.Adapter = adapter;
        }
コード例 #4
0
        public Form1()
        {
            InitializeComponent();

            try
            {
                log.Info("Elements initialization was started.");

                graphics = clockPanel.CreateGraphics();

                rectangle         = clockPanel.DisplayRectangle;
                hrHand            = rectangle.Height / 4;
                secHand           = hrHand * 1.5;
                minHand           = hrHand * 1.3;
                center            = new Point(clockPanel.Width / 2, clockPanel.Height / 2);
                secondBox.Enabled = false;
                minuteBox.Enabled = false;
                hourBox.Enabled   = false;

                digitalClock = new DigitalClock();
                clockAdapter = new ClockAdapter(digitalClock);
                analogClock  = new AnalogClock();
                log.Info("The Clocks have been initialized successfuly.");

                Paint         += new PaintEventHandler(DrawClock);
                timer          = new Timer();
                timer.Interval = 1000;
                timer.Tick    += new EventHandler(TimerTick);
                timer.Start();

                log.Info("Elements initialization was finished successfuly.");
            }
            catch (ArgumentNullException ex)
            {
                log.Error(ex.Message);
                log.Error(ex.StackTrace);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                log.Error(ex.StackTrace);
            }
        }