android.app.ActionBar.Tab Java Examples

The following examples show how to use android.app.ActionBar.Tab. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From pixate-freestyle-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    Tab tab = actionBar.newTab().setText(R.string.tab1_title)
            .setTabListener(new TabListener(this, Fragment1.class.getName()));
    actionBar.addTab(tab);
    tab = actionBar.newTab().setText(R.string.tab2_title)
            .setTabListener(new TabListener(this, Fragment2.class.getName()));
    actionBar.addTab(tab);
    tab = actionBar.newTab().setText(R.string.tab3_title)
            .setTabListener(new TabListener(this, Fragment3.class.getName()));
    actionBar.addTab(tab);

    // Initiate Pixate
    PixateFreestyle.init(this);
}
 
Example #2
Source File: DialtactsActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (mInSearchUi) {
        prepareOptionsMenuInSearchMode(menu);
    } else {
        // get reference to the currently selected tab
        final Tab tab = getActionBar().getSelectedTab();
        if (tab != null) {
            switch(tab.getPosition()) {
                case TAB_INDEX_DIALER:
                    prepareOptionsMenuForDialerTab(menu);
                    break;
                case TAB_INDEX_CALL_LOG:
                    prepareOptionsMenuForCallLogTab(menu);
                    break;
                case TAB_INDEX_FAVORITES:
                    prepareOptionsMenuForFavoritesTab(menu);
                    break;
            }
        }
    }
    return true;
}
 
Example #3
Source File: TabbedActivity.java    From holoaccent with Apache License 2.0 6 votes vote down vote up
protected void configureTabs(final ActionBar actionBar, ViewPager viewPager) {
	
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
				@Override public void onPageSelected(int position) {
					actionBar.setSelectedNavigationItem(position);
				}
			});

	// For each of the sections in the app, add a tab to the action bar.
	for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
		Tab newTab = actionBar.newTab()
				.setText(mSectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this);
		actionBar.addTab(newTab);
	}
}
 
Example #4
Source File: FragmentNestingStatePagerSupport.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    Object tag = tab.getTag();
    for (int i=0; i<mTabs.size(); i++) {
        if (mTabs.get(i) == tag) {
            mViewPager.setCurrentItem(i);
        }
    }
}
 
Example #5
Source File: FragmentTabs.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    if (mFragment == null) {
        mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs);
        ft.add(android.R.id.content, mFragment, mTag);
    } else {
        ft.attach(mFragment);
    }
}
 
Example #6
Source File: AllEventFRAGMENT.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	// TODO 自动生成的方法存根
	String text = (String) tab.getText() ;
	if(text.equals("活动广场")) {
		mViewPager1.setCurrentItem(0);
	}
	if(text.equals("好友的活动")) {
		mViewPager1.setCurrentItem(1);
	}
}
 
Example #7
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	// Check if the fragment is already initialized
	if (mFragment == null) {
		// If not, instantiate and add it to the activity
		mFragment = Fragment.instantiate(mActivity, mClass.getName());
		ft.add(android.R.id.content, mFragment, mTag);
	} else {
		// If it exists, simply attach it in order to show it
		ft.setCustomAnimations(android.R.animator.fade_in,
				R.animator.animationtest);
		ft.attach(mFragment);
	}
}
 
Example #8
Source File: MyHomePageFRAGMENT.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	// TODO 自动生成的方法存根
	String text = (String) tab.getText() ;
	if(text.equals("我组织的")) {
		mViewPager0.setCurrentItem(0);
	}
	if(text.equals("我参加的")) {
		mViewPager0.setCurrentItem(1);
	}
}
 
Example #9
Source File: GlimmrPagerAdapter.java    From glimmr with Apache License 2.0 5 votes vote down vote up
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    String tabText = tab.getText().toString();
    for (int i=0; i<mContent.length; i++) {
        if (tabText.equalsIgnoreCase(mContent[i])) {
            mViewPager.setCurrentItem(i);
        }
    }
}
 
Example #10
Source File: MainActivity.java    From aard2-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTabUnselected(ActionBar.Tab tab,
        FragmentTransaction fragmentTransaction) {
    Fragment frag = appSectionsPagerAdapter.getItem(tab.getPosition());
    if (frag instanceof BaseListFragment) {
        ((BaseListFragment)frag).finishActionMode();
    }
    if (tab.getPosition() == 0) {
        View v = this.getCurrentFocus();
        if (v != null){
            InputMethodManager mgr = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}
 
Example #11
Source File: TabListener.java    From adapter-kit with Apache License 2.0 5 votes vote down vote up
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	// Check if the fragment is already initialized
	if (mFragment == null) {
		// If not, instantiate and add it to the activity
		mFragment = Fragment.instantiate(mActivity, mClass.getName());
		ft.add(android.R.id.content, mFragment, mTag);
	} else {
		// If it exists, simply attach it in order to show it
		ft.attach(mFragment);
	}
}
 
Example #12
Source File: SamplesActivity.java    From adapter-kit with Apache License 2.0 5 votes vote down vote up
private void initTabs() {
	ActionBar actionBar = this.getActionBar();
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	Tab tab1 = actionBar
			.newTab()
			.setText("Simple List")
			.setTabListener(
					new TabListener<SimpleListFragment>(this,
							"simple_list", SimpleListFragment.class));
	actionBar.addTab(tab1);

	Tab tab2 = actionBar
			.newTab()
			.setText("Sectioned List")
			.setTabListener(
					new TabListener<SectionedListFragment>(this,
							"sectioned_list", SectionedListFragment.class));
	actionBar.addTab(tab2);

	Tab tab3 = actionBar
			.newTab()
			.setText("Circular List")
			.setTabListener(
					new TabListener<CircularListFragment>(this,
							"circular_list", CircularListFragment.class));
	actionBar.addTab(tab3);
}
 
Example #13
Source File: FragmentNestingPagerSupport.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
    TabInfo info = new TabInfo(clss, args);
    tab.setTag(info);
    tab.setTabListener(this);
    mTabs.add(info);
    mActionBar.addTab(tab);
    notifyDataSetChanged();
}
 
Example #14
Source File: TabLayoutActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
	Log.i(TAG, "onTabUnselected called");

	if (null != mFragment)
		ft.remove(mFragment);
}
 
Example #15
Source File: TabLayoutActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	Log.i(TAG, "onTabSelected called");

	if (null != mFragment) {
		ft.replace(R.id.fragment_container, mFragment);
	}
}
 
Example #16
Source File: DialtactsActivity.java    From coursera-android with MIT License 5 votes vote down vote up
private void setupFavorites() {
    final Tab tab = getActionBar().newTab();
    tab.setContentDescription(R.string.contactsFavoritesLabel);
    tab.setIcon(R.drawable.ic_tab_all);
    tab.setTabListener(mTabListener);
    getActionBar().addTab(tab);
}
 
Example #17
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
	if (mFragment != null) {
		ft.setCustomAnimations(android.R.animator.fade_in,
				R.animator.test);
		ft.detach(mFragment);
	}
}
 
Example #18
Source File: DialtactsActivity.java    From coursera-android with MIT License 5 votes vote down vote up
private void setupDialer() {
    final Tab tab = getActionBar().newTab();
    tab.setContentDescription(R.string.dialerIconLabel);
    tab.setTabListener(mTabListener);
    tab.setIcon(R.drawable.ic_tab_dialer);
    getActionBar().addTab(tab);
}
 
Example #19
Source File: DialtactsActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    if (DEBUG) {
        Log.d(TAG, "onTabSelected(). tab: " + tab + ", mDuringSwipe: " + mDuringSwipe);
    }
    // When the user swipes the screen horizontally, this method will be called after
    // ViewPager.SCROLL_STATE_DRAGGING and ViewPager.SCROLL_STATE_SETTLING events, while
    // when the user clicks a tab at the ActionBar at the top, this will be called before
    // them. This logic interprets the order difference as a difference of the user action.
    if (!mDuringSwipe) {
        if (DEBUG) {
            Log.d(TAG, "Tab select. from: " + mPageChangeListener.getCurrentPosition()
                    + ", to: " + tab.getPosition());
        }
        if (mDialpadFragment != null) {
            updateFakeMenuButtonsVisibility(tab.getPosition() == TAB_INDEX_DIALER);
        }
        mUserTabClick = true;
    }

    if (mViewPager.getCurrentItem() != tab.getPosition()) {
        mViewPager.setCurrentItem(tab.getPosition(), true);
    }

    // During the call, we don't remember the tab position.
    if (!DialpadFragment.phoneIsInUse()) {
        // Remember this tab index. This function is also called, if the tab is set
        // automatically in which case the setter (setCurrentTab) has to set this to its old
        // value afterwards
        mLastManuallySelectedFragment = tab.getPosition();
    }
}
 
Example #20
Source File: FragmentNestingPagerSupport.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    Object tag = tab.getTag();
    for (int i=0; i<mTabs.size(); i++) {
        if (mTabs.get(i) == tag) {
            mViewPager.setCurrentItem(i);
        }
    }
}
 
Example #21
Source File: TabbedActivity.java    From holoaccent with Apache License 2.0 5 votes vote down vote up
@Override
public void onTabSelected(ActionBar.Tab tab,
		FragmentTransaction fragmentTransaction) {
	// When the given tab is selected, switch to the corresponding page in
	// the ViewPager.
	mViewPager.setCurrentItem(tab.getPosition());
}
 
Example #22
Source File: FragmentNestingPagerSupport.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
 
Example #23
Source File: TabListener.java    From adapter-kit with Apache License 2.0 4 votes vote down vote up
public void onTabReselected(Tab tab, FragmentTransaction ft) {
	// User selected the already selected tab. Usually do nothing.
}
 
Example #24
Source File: TabsListener.java    From android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Se ha seleccionado una pestaña. Se carga en la pantalla
 */
public void onTabSelected(Tab tab, FragmentTransaction ft) {
	
	ft.replace(R.id.contenedor, fragmento);
}
 
Example #25
Source File: ActionBarTabsPager.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
 
Example #26
Source File: TabsListener.java    From android with GNU General Public License v2.0 4 votes vote down vote up
/**
    * La pestaña se ha re-seleccionado
    */
public void onTabReselected(Tab tab, FragmentTransaction ft) {
	
	// Aquí por ejemplo se podría refrescar la vista
       ft.replace(R.id.contenedor, fragmento);
}
 
Example #27
Source File: ActionBarTabsPager.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
 
Example #28
Source File: FragmentNestingPagerSupport.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
 
Example #29
Source File: FragmentNestingStatePagerSupport.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
 
Example #30
Source File: ActionBarTabs.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public void onTabReselected(Tab tab, FragmentTransaction ft) {
    Toast.makeText(ActionBarTabs.this, "Reselected!", Toast.LENGTH_SHORT).show();
}