예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            
            SetContentView(Resource.Layout.other);

            MenuId = Resource.Menu.mainmenu;

			ActionBar = FindViewById<Library.ActionBar>(Resource.Id.actionbar);
            // You can also assign the title programmatically by passing a
            // CharSequence or resource id.
            ActionBar.Title = "Other Activity";
            AddHomeAction(typeof(HomeActivity));
            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<Library.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);
            _tabHost = FindViewById<TabHost>(Android.Resource.Id.TabHost);
            _tabHost.Setup();

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

            _tabsAdapter = new TabsAdapter(this, _tabHost, _viewPager);


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

            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 = _tabHost.NewTabSpec("tv");
            spec.SetIndicator("Tab 1", Resources.GetDrawable(Resource.Drawable.ic_launcher));
            _tabsAdapter.AddTab(spec, Java.Lang.Class.FromType(typeof(FramgmentTab1)), null);


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

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

                _tabHost.CurrentTab = 0;
            }
        }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

			ActionBar = FindViewById<Library.ActionBar>(Resource.Id.actionbar);
            ActionBar.CurrentActivity = this;
            ActionBar.SetHomeLogo(Resource.Drawable.ic_launcher);


            /*
             * 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();
            };

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


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