示例#1
0
        public override void removeTabAt(int position)
        {
            if (mTabScrollView == null)
            {
                // No tabs around to remove
                return;
            }
            int selectedTabPosition = mSelectedTab != null?mSelectedTab.getPosition() : mSavedTabPosition;

            mTabScrollView.removeTabAt(position);
            [email protected] removedTab = mTabs.remove(position);
            if (removedTab != null)
            {
                removedTab.setPosition(-1);
            }
            int newTabCount = mTabs.size();

            {
                for (int i = position; i < newTabCount; i++)
                {
                    mTabs.get(i).setPosition(i);
                }
            }
            if (selectedTabPosition == position)
            {
                selectTab(mTabs.isEmpty() ? null : mTabs.get(System.Math.Max(0, position - 1)));
            }
        }
示例#2
0
 private void configureTab(android.app.ActionBar.Tab tab, int position)
 {
     [email protected] tabi = ([email protected]
                                                         .TabImpl)tab;
     android.app.ActionBar.TabListener callback = tabi.getCallback();
     if (callback == null)
     {
         throw new System.InvalidOperationException("Action Bar Tab must have a Callback");
     }
     tabi.setPosition(position);
     mTabs.add(position, tabi);
     int count = mTabs.size();
     {
         for (int i = position + 1; i < count; i++)
         {
             mTabs.get(i).setPosition(i);
         }
     }
 }
示例#3
0
        public override void selectTab(android.app.ActionBar.Tab tab)
        {
            if (getNavigationMode() != NAVIGATION_MODE_TABS)
            {
                mSavedTabPosition = tab != null?tab.getPosition() : INVALID_POSITION;

                return;
            }
            android.app.FragmentTransaction trans = mActivity.getFragmentManager().beginTransaction
                                                        ().disallowAddToBackStack();
            if (mSelectedTab == tab)
            {
                if (mSelectedTab != null)
                {
                    mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
                    mTabScrollView.animateToTab(tab.getPosition());
                }
            }
            else
            {
                mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : android.app.ActionBar
                                              .Tab.INVALID_POSITION);
                if (mSelectedTab != null)
                {
                    mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
                }
                mSelectedTab = ([email protected])tab;
                if (mSelectedTab != null)
                {
                    mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
                }
            }
            if (!trans.isEmpty())
            {
                trans.commit();
            }
        }
示例#4
0
		public override void selectTab(android.app.ActionBar.Tab tab)
		{
			if (getNavigationMode() != NAVIGATION_MODE_TABS)
			{
				mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION;
				return;
			}
			android.app.FragmentTransaction trans = mActivity.getFragmentManager().beginTransaction
				().disallowAddToBackStack();
			if (mSelectedTab == tab)
			{
				if (mSelectedTab != null)
				{
					mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
					mTabScrollView.animateToTab(tab.getPosition());
				}
			}
			else
			{
				mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : android.app.ActionBar
					.Tab.INVALID_POSITION);
				if (mSelectedTab != null)
				{
					mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
				}
				mSelectedTab = ([email protected])tab;
				if (mSelectedTab != null)
				{
					mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
				}
			}
			if (!trans.isEmpty())
			{
				trans.commit();
			}
		}