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

            
            SetContentView(Resource.Layout.Other);

            MenuId = Resource.Menu.MainMenu;

            ActionBar = FindViewById<ActionBar>(Resource.Id.actionbar);
            // You can also assign the title programmatically by passing a
            // CharSequence or resource id.
            ActionBar.Title = "Other Activity";
            AddHomeAction();
            ActionBar.CurrentActivity = this;

            var itemActionBarAction = new MenuItemActionBarAction(
                this, this, Resource.Id.menu_search,
                Resource.Drawable.ic_action_search_dark,
                Resource.String.menu_string_search)
                                          {
                                              ActionType = ActionType.Always
                                          };
            ActionBar.AddAction(itemActionBarAction);

            itemActionBarAction = new MenuItemActionBarAction(
                this, this, Resource.Id.menu_refresh,
                Resource.Drawable.ic_action_refresh_dark,
                Resource.String.menu_string_refresh)
                                      {ActionType = ActionType.Never};
            ActionBar.AddAction(itemActionBarAction);

            var bottomActionBar = FindViewById<ActionBar>(Resource.Id.bottomActionbar);

            var action = new MenuItemActionBarAction(this, this, Resource.Id.menu_up, Resource.Drawable.ic_action_up, Resource.String.menu_string_down)
                             {
                               ActionType = ActionType.Always
                             };

            bottomActionBar.AddAction(action);
            action = new MenuItemActionBarAction(this, this, Resource.Id.menu_down, Resource.Drawable.ic_action_down, Resource.String.menu_string_down)
                            {
                                ActionType = ActionType.Always
                            };
            bottomActionBar.AddAction(action);

            action = new MenuItemActionBarAction(this, this, Resource.Id.menu_left, Resource.Drawable.ic_action_left, Resource.String.menu_string_left)
                            {
                                ActionType = ActionType.Always
                            };
            bottomActionBar.AddAction(action);

            action = new MenuItemActionBarAction(this, this, Resource.Id.menu_right, Resource.Drawable.ic_action_right, Resource.String.menu_string_right)
                            {
                                ActionType = ActionType.Always
                            };
            bottomActionBar.AddAction(action);

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


            MenuId = Resource.Menu.MainMenu;

            SetContentView(Resource.Layout.fragment_tabs);
            m_TabHost = FindViewById<TabHost>(Android.Resource.Id.TabHost);
            m_TabHost.Setup();

            m_ViewPager = FindViewById<ViewPager>(Resource.Id.pager);

            m_TabsAdapter = new TabsAdapter(this, m_TabHost, m_ViewPager);


            ActionBar = FindViewById<ActionBar>(Resource.Id.actionbar);
            ActionBar.Title = "Look Fragments";
            ActionBar.CurrentActivity = this;
            AddHomeAction();
         

            var action = new MenuItemActionBarAction(this, this, Resource.Id.menu_search, Resource.Drawable.ic_action_search_dark, Resource.String.menu_string_search);
            ActionBar.AddAction(action);


            var spec = m_TabHost.NewTabSpec("tv");
            spec.SetIndicator("Tab 1", Resources.GetDrawable(Resource.Drawable.ic_launcher));
            m_TabsAdapter.AddTab(spec, Java.Lang.Class.FromType(typeof(FramgmentTab1)), null);


            spec = m_TabHost.NewTabSpec("tab2");
            spec.SetIndicator("Tab 2", Resources.GetDrawable(Resource.Drawable.ic_launcher));
            m_TabsAdapter.AddTab(spec, Java.Lang.Class.FromType(typeof(FramgmentTab2)), null);

            if (bundle != null)
            {
                m_TabHost.SetCurrentTabByTag(bundle.GetString("tab"));
            }
            else
            {

                m_TabHost.CurrentTab = 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;
            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();
            };
        }
示例#4
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();
            };
        }