protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var actionBar = FindViewById<ActionBar>(Resource.Id.actionbar);
            m_ActionBar = actionBar;
            m_ActionBar.CurrentActivity = this;
            actionBar.SetTitle("BingBong");

            //always put these 2 in there since they are NOT in my menu.xml
            ActionBarAction shareAction = new MyActionBarAction(this, CreateShareIntent(), Resource.Drawable.ic_title_share_default)
            {
                ActionType = ActionType.Always
            };
            actionBar.AddAction(shareAction);
            

            var otherAction = new MyActionBarAction(this, new Intent(this, typeof(OtherActivity)), Resource.Drawable.ic_title_export_default)
            {
                ActionType = ActionType.Always
            };
            actionBar.AddAction(otherAction);

            //only put in if there is room
            var searchMenuItemAction = new MenuItemActionBarAction(
                this, this, Resource.Id.menu_search,
                Resource.Drawable.ic_action_search_dark,
                Resource.String.menu_string_search)
                                           {
                                               ActionType = ActionType.IfRoom
                                           };
            actionBar.AddAction(searchMenuItemAction);
            
            //never put this guy in there
            searchMenuItemAction = new MenuItemActionBarAction(
                this, this, Resource.Id.menu_refresh,
                Resource.Drawable.ic_action_refresh_dark,
                Resource.String.menu_string_refresh)
                                       {
                                           ActionType = ActionType.Never
                                       };
            actionBar.AddAction(searchMenuItemAction);
            
            var startProgress = FindViewById<Button>(Resource.Id.start_progress);
            startProgress.Click += (s, e) => actionBar.ProgressBarVisibility = ViewStates.Visible;

            var stopProgress = FindViewById<Button>(Resource.Id.stop_progress);
            stopProgress.Click += (s, e) => actionBar.ProgressBarVisibility = ViewStates.Gone;

            var removeActions = FindViewById<Button>(Resource.Id.remove_actions);
            removeActions.Click += (s, e) => actionBar.RemoveAllActions();

            var removeShareAction = FindViewById<Button>(Resource.Id.remove_share_action);
            removeShareAction.Click += (s, e) => actionBar.RemoveAction(shareAction);
            
            var addAction = FindViewById<Button>(Resource.Id.add_action);
            addAction.Click += (s, e) =>
            {
                var action = new MyOtherActionBarAction(this, null, Resource.Drawable.ic_title_share_default);
                actionBar.AddAction(action);
            };

            var removeAction = FindViewById<Button>(Resource.Id.remove_action);
            removeAction.Click += (s, e) =>
            {
                actionBar.RemoveActionAt(actionBar.ActionCount - 1);
                Toast.MakeText(this, "Removed action.", ToastLength.Short).Show();
            };
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.main);

            LegacyBar = FindViewById<Library.Bar.LegacyBar>(Resource.Id.actionbar);
            LegacyBar.SetHomeLogo(Resource.Drawable.icon);

            /*
             * You can also set the title of the LegacyBar with: 
             * LegacyBar.Title = "MyAwesomeTitle";
             * 
             * or
             * 
             * LegacyBar.Title = Resource.String.<yourStringId>;
             * 
             * Title Color can be set with:
             * LegacyBar.TitleColor = Color.Blue; //Or any other Color you want
             * 
             * The Separator between the Action Bar Items can be set with:
             * LegacyBar.SeparatorColor = Color.Blue;
             * 
             * and with a drawable:
             * 
             * LegacyBar.SeparatorDrawable = myDrawable;
             */

            //always put these 2 in there since they are NOT in my menu.xml
            MenuId = Resource.Menu.mainmenu;

            LegacyBarAction shareAction = new DefaultLegacyBarAction(this, CreateShareIntent(),
                                                                     LegacyBar.LightIcons ? Resource.Drawable.ic_action_sort : Resource.Drawable.ic_action_sort_dark)
                                              {
                                                  ActionType = ActionType.Always
                                              };
            LegacyBar.AddAction(shareAction);


            var otherAction = new DefaultLegacyBarAction(this, new Intent(this, typeof (OtherActivity)),
                                                         LegacyBar.LightIcons ? Resource.Drawable.ic_action_share : Resource.Drawable.ic_action_share_dark)
                                  {
                                      ActionType = ActionType.Always
                                  };
            LegacyBar.AddAction(otherAction);

            //only put in if there is room
            var searchMenuItemAction = new MenuItemLegacyBarAction(
                this, Resource.Id.menu_search, LegacyBar.LightIcons ? Resource.Drawable.ic_action_share : Resource.Drawable.ic_action_share_dark,
                Resource.String.menu_string_search)
                                           {
                                               ActionType = ActionType.IfRoom
                                           };
            LegacyBar.AddAction(searchMenuItemAction);

            //never put this guy in there
            searchMenuItemAction = new MenuItemLegacyBarAction(
                this, Resource.Id.menu_refresh, LegacyBar.LightIcons ? Resource.Drawable.ic_action_refresh : Resource.Drawable.ic_action_refresh_dark,
                Resource.String.menu_string_refresh)
                                       {
                                           ActionType = ActionType.Never
                                       };
            LegacyBar.AddAction(searchMenuItemAction);

            var startProgress = FindViewById<Button>(Resource.Id.start_progress);
            startProgress.Click += (s, e) => LegacyBar.ProgressBarVisibility = ViewStates.Visible;

            var stopProgress = FindViewById<Button>(Resource.Id.stop_progress);
            stopProgress.Click += (s, e) => LegacyBar.ProgressBarVisibility = ViewStates.Gone;

            var removeActions = FindViewById<Button>(Resource.Id.remove_actions);
            removeActions.Click += (s, e) => LegacyBar.RemoveAllActions();

            var removeShareAction = FindViewById<Button>(Resource.Id.remove_share_action);
            removeShareAction.Click += (s, e) => LegacyBar.RemoveAction(shareAction);

            var addAction = FindViewById<Button>(Resource.Id.add_action);
            addAction.Click += (s, e) =>
                                   {
                                       var action = new MyOtherActionBarAction(this, null, LegacyBar.LightIcons ? Resource.Drawable.ic_action_share : Resource.Drawable.ic_action_share_dark);
                                       LegacyBar.AddAction(action);
                                   };

            var removeAction = FindViewById<Button>(Resource.Id.remove_action);
            removeAction.Click += (s, e) =>
                                      {
                                          LegacyBar.RemoveActionAt(LegacyBar.ActionCount - 1);
                                          Toast.MakeText(this, "Removed legacyBarAction.", ToastLength.Short).Show();
                                      };

            var otherActivity = FindViewById<Button>(Resource.Id.other_activity);
            otherActivity.Click += (s, e) =>
                                       {
                                           var intent = new Intent(this, typeof (OtherActivity));
                                           StartActivity(intent);
                                       };

            var black = FindViewById<Button>(Resource.Id.black_activity);
            black.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int)LegacyBarTheme.HoloBlack);
                StartActivity(intent);
            };

            var blue = FindViewById<Button>(Resource.Id.blue_activity);
            blue.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int)LegacyBarTheme.HoloBlue);
                StartActivity(intent);
            };

            var light = FindViewById<Button>(Resource.Id.light_activity);
            light.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int)LegacyBarTheme.HoloLight);
                StartActivity(intent);
            };

            var gray = FindViewById<Button>(Resource.Id.gray_activity);
            gray.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int) LegacyBarTheme.HoloGray);
                StartActivity(intent);
            };


            var fragmentActivity = FindViewById<Button>(Resource.Id.fragment_activity);
            fragmentActivity.Click += (s, e) =>
                                          {
                                              var intent = new Intent(this, typeof (FragmentTabActivity));
                                              StartActivity(intent);
                                          };

            var spinnerActivity = FindViewById<Button>(Resource.Id.dropdown_activity);
            spinnerActivity.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(SpinnerActivity));
                StartActivity(intent);
            };
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var actionBar = FindViewById<ActionBar>(Resource.Id.actionbar);
            m_ActionBar = actionBar;
            m_ActionBar.CurrentActivity = this;

            /*
             * You can also set the title of the ActionBar with: 
             * actionBar.Title = "MyAwesomeTitle";
             * 
             * or
             * 
             * actionBar.Title = Resource.String.<yourStringId>;
             * 
             * Title Color can be set with:
             * actionBar.TitleColor = Color.Blue; //Or any other Color you want
             * 
             * The Separator between the Action Bar Items can be set with:
             * actionBar.SeparatorColor = Color.Blue;
             * 
             * and with a drawable:
             * 
             * actionBar.SeparatorDrawable = myDrawable;
             */

            //always put these 2 in there since they are NOT in my menu.xml
            ActionBarAction shareAction = new MyActionBarAction(this, CreateShareIntent(), Resource.Drawable.ic_title_share_default)
            {
                ActionType = ActionType.Always
            };
            actionBar.AddAction(shareAction);
            

            var otherAction = new MyActionBarAction(this, new Intent(this, typeof(OtherActivity)), Resource.Drawable.ic_title_export_default)
            {
                ActionType = ActionType.Always
            };
            actionBar.AddAction(otherAction);

            //only put in if there is room
            var searchMenuItemAction = new MenuItemActionBarAction(
                this, this, Resource.Id.menu_search,
                Resource.Drawable.ic_action_search_dark,
                Resource.String.menu_string_search)
                                           {
                                               ActionType = ActionType.IfRoom
                                           };
            actionBar.AddAction(searchMenuItemAction);
            
            //never put this guy in there
            searchMenuItemAction = new MenuItemActionBarAction(
                this, this, Resource.Id.menu_refresh,
                Resource.Drawable.ic_action_refresh_dark,
                Resource.String.menu_string_refresh)
                                       {
                                           ActionType = ActionType.Never
                                       };
            actionBar.AddAction(searchMenuItemAction);
            
            var startProgress = FindViewById<Button>(Resource.Id.start_progress);
            startProgress.Click += (s, e) => actionBar.ProgressBarVisibility = ViewStates.Visible;

            var stopProgress = FindViewById<Button>(Resource.Id.stop_progress);
            stopProgress.Click += (s, e) => actionBar.ProgressBarVisibility = ViewStates.Gone;

            var removeActions = FindViewById<Button>(Resource.Id.remove_actions);
            removeActions.Click += (s, e) => actionBar.RemoveAllActions();

            var removeShareAction = FindViewById<Button>(Resource.Id.remove_share_action);
            removeShareAction.Click += (s, e) => actionBar.RemoveAction(shareAction);
            
            var addAction = FindViewById<Button>(Resource.Id.add_action);
            addAction.Click += (s, e) =>
            {
                var action = new MyOtherActionBarAction(this, null, Resource.Drawable.ic_title_share_default);
                actionBar.AddAction(action);
            };

            var removeAction = FindViewById<Button>(Resource.Id.remove_action);
            removeAction.Click += (s, e) =>
            {
                actionBar.RemoveActionAt(actionBar.ActionCount - 1);
                Toast.MakeText(this, "Removed action.", ToastLength.Short).Show();
            };
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.main);

            LegacyBar = FindViewById <Library.Bar.LegacyBar>(Resource.Id.actionbar);
            LegacyBar.SetHomeLogo(Resource.Drawable.icon);

            /*
             * You can also set the title of the LegacyBar with:
             * LegacyBar.Title = "MyAwesomeTitle";
             *
             * or
             *
             * LegacyBar.Title = Resource.String.<yourStringId>;
             *
             * Title Color can be set with:
             * LegacyBar.TitleColor = Color.Blue; //Or any other Color you want
             *
             * The Separator between the Action Bar Items can be set with:
             * LegacyBar.SeparatorColor = Color.Blue;
             *
             * and with a drawable:
             *
             * LegacyBar.SeparatorDrawable = myDrawable;
             */

            //always put these 2 in there since they are NOT in my menu.xml
            MenuId = Resource.Menu.mainmenu;

            LegacyBarAction shareAction = new DefaultLegacyBarAction(this, CreateShareIntent(),
                                                                     LegacyBar.LightIcons ? Resource.Drawable.ic_action_sort : Resource.Drawable.ic_action_sort_dark)
            {
                ActionType = ActionType.Always
            };

            LegacyBar.AddAction(shareAction);


            var otherAction = new DefaultLegacyBarAction(this, new Intent(this, typeof(OtherActivity)),
                                                         LegacyBar.LightIcons ? Resource.Drawable.ic_action_share : Resource.Drawable.ic_action_share_dark)
            {
                ActionType = ActionType.Always
            };

            LegacyBar.AddAction(otherAction);

            //only put in if there is room
            var searchMenuItemAction = new MenuItemLegacyBarAction(
                this, Resource.Id.menu_search, LegacyBar.LightIcons ? Resource.Drawable.ic_action_share : Resource.Drawable.ic_action_share_dark,
                Resource.String.menu_string_search)
            {
                ActionType = ActionType.IfRoom
            };

            LegacyBar.AddAction(searchMenuItemAction);

            //never put this guy in there
            searchMenuItemAction = new MenuItemLegacyBarAction(
                this, Resource.Id.menu_refresh, LegacyBar.LightIcons ? Resource.Drawable.ic_action_refresh : Resource.Drawable.ic_action_refresh_dark,
                Resource.String.menu_string_refresh)
            {
                ActionType = ActionType.Never
            };
            LegacyBar.AddAction(searchMenuItemAction);

            var startProgress = FindViewById <Button>(Resource.Id.start_progress);

            startProgress.Click += (s, e) => LegacyBar.ProgressBarVisibility = ViewStates.Visible;

            var stopProgress = FindViewById <Button>(Resource.Id.stop_progress);

            stopProgress.Click += (s, e) => LegacyBar.ProgressBarVisibility = ViewStates.Gone;

            var removeActions = FindViewById <Button>(Resource.Id.remove_actions);

            removeActions.Click += (s, e) => LegacyBar.RemoveAllActions();

            var removeShareAction = FindViewById <Button>(Resource.Id.remove_share_action);

            removeShareAction.Click += (s, e) => LegacyBar.RemoveAction(shareAction);

            var addAction = FindViewById <Button>(Resource.Id.add_action);

            addAction.Click += (s, e) =>
            {
                var action = new MyOtherActionBarAction(this, null, LegacyBar.LightIcons ? Resource.Drawable.ic_action_share : Resource.Drawable.ic_action_share_dark);
                LegacyBar.AddAction(action);
            };

            var removeAction = FindViewById <Button>(Resource.Id.remove_action);

            removeAction.Click += (s, e) =>
            {
                LegacyBar.RemoveActionAt(LegacyBar.ActionCount - 1);
                Toast.MakeText(this, "Removed legacyBarAction.", ToastLength.Short).Show();
            };

            var otherActivity = FindViewById <Button>(Resource.Id.other_activity);

            otherActivity.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                StartActivity(intent);
            };

            var black = FindViewById <Button>(Resource.Id.black_activity);

            black.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int)LegacyBarTheme.HoloBlack);
                StartActivity(intent);
            };

            var blue = FindViewById <Button>(Resource.Id.blue_activity);

            blue.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int)LegacyBarTheme.HoloBlue);
                StartActivity(intent);
            };

            var light = FindViewById <Button>(Resource.Id.light_activity);

            light.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int)LegacyBarTheme.HoloLight);
                StartActivity(intent);
            };

            var gray = FindViewById <Button>(Resource.Id.gray_activity);

            gray.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(OtherActivity));
                intent.PutExtra("Theme", (int)LegacyBarTheme.HoloGray);
                StartActivity(intent);
            };


            var fragmentActivity = FindViewById <Button>(Resource.Id.fragment_activity);

            fragmentActivity.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(FragmentTabActivity));
                StartActivity(intent);
            };

            var spinnerActivity = FindViewById <Button>(Resource.Id.dropdown_activity);

            spinnerActivity.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(SpinnerActivity));
                StartActivity(intent);
            };
        }