Ejemplo n.º 1
0
        private void addStatusView()
        {
            if (statsView != null)
            {
                return;
            }
            statsView = new StatsView(this, this);
            WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams(WindowManagerLayoutParams.MatchParent, WindowManagerLayoutParams.WrapContent, WindowManagerTypes.SystemOverlay, WindowManagerFlags.NotFocusable | WindowManagerFlags.NotTouchable, Format.Translucent);

            layoutParams.Gravity = GravityFlags.Right | GravityFlags.Top;
            layoutParams.Title   = "Load Average";
            mTabHost.AddView(statsView, layoutParams);
            statsView.SetBackgroundColor(Color.Black);
        }
Ejemplo n.º 2
0
        private Task <IDialogAnswer <DateTime> > ShowDateTimeDialog(string caption, DateTime current, bool date, bool time
                                                                    , IDialogButton positive, IDialogButton negative)
        {
            var tsc = new TaskCompletionSource <IDialogAnswer <DateTime> >();

            var builder = CreateBuilder();

            builder.SetTitle(caption);

            using (var th = new TabHost(_activity))
            {
                th.Id = Android.Resource.Id.TabHost;

                var widget = new TabWidget(_activity)
                {
                    Id = Android.Resource.Id.Tabs
                };

                var fl = new FrameLayout(_activity)
                {
                    Id = Android.Resource.Id.TabContent
                };
                var rll = new LinearLayout(_activity)
                {
                    Orientation = Orientation.Vertical
                };
                rll.SetBackgroundColor(new Color(50, 100, 145));
                rll.AddView(widget);
                rll.AddView(fl);
                fl.LayoutParameters.Width = ViewGroup.LayoutParams.MatchParent;

                th.AddView(rll);

                th.Setup();

                var tabContentFactory = new TabContentFactory();

                if (date)
                {
                    var dp = new DatePicker(_activity)
                    {
                        Id = DatePicker
                    };
                    var minDate = new DateTime(1900, 1, 1);
                    current     = current > minDate ? current : minDate;
                    dp.DateTime = current;

                    tabContentFactory.Add("date", dp);
                    var spec = th.NewTabSpec("date");
                    spec.SetContent(tabContentFactory);
                    spec.SetIndicator(CreateTabIndicator(D.DATE));
                    th.AddTab(spec);
                }
                if (time)
                {
                    var tp = new TimePicker(_activity)
                    {
                        Id = TimePicker
                    };
                    tp.SetIs24HourView(new Java.Lang.Boolean(true));
                    tp.CurrentHour   = new Java.Lang.Integer(current.Hour);
                    tp.CurrentMinute = new Java.Lang.Integer(current.Minute);

                    tabContentFactory.Add("time", tp);
                    var spec = th.NewTabSpec("time");
                    spec.SetContent(tabContentFactory);
                    spec.SetIndicator(CreateTabIndicator(D.TIME));
                    th.AddTab(spec);
                }

                widget.SetCurrentTab(0);
                builder.SetView(th);
            }
            builder.SetPositiveButton(positive.Caption, (sender, e) =>
            {
                DateTime result = DateTimeFromDialog(sender, current, date, time);
                tsc.SetResult(new DialogAnswer <DateTime>(true, result));
            });
            builder.SetNegativeButton(negative.Caption, (sender, e) =>
            {
                DateTime result = DateTimeFromDialog(sender, current, date, time);
                tsc.SetResult(new DialogAnswer <DateTime>(false, result));
            });
            builder.SetCancelable(false);

            ShowDialog(builder);

            return(tsc.Task);
        }