Java Code Examples for android.support.v7.app.ActionBar#Tab

The following examples show how to use android.support.v7.app.ActionBar#Tab . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activty_about);

    actionBar = getSupportActionBar();
    viewPager = (ViewPager) findViewById(R.id.pager);
    TabsPagerAdapter adapter = new TabsPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);
    actionBar.setDisplayHomeAsUpEnabled(true);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);

    ActionBar.Tab tabFirst = actionBar.newTab().setText(getString(R.string.about_tab_1)).setTabListener(this);
    ActionBar.Tab tabSecond = actionBar.newTab().setText(getString(R.string.about_tab_2)).setTabListener(this);
    ActionBar.Tab tabThird = actionBar.newTab().setText(getString(R.string.about_tab_3)).setTabListener(this);

    actionBar.addTab(tabFirst);
    actionBar.addTab(tabSecond);
    actionBar.addTab(tabThird);
    actionBar.selectTab(tabFirst);
}
 
Example 2
Source Project: sms-ticket   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
    mSelectedTab = tab.getPosition();
    String selectedTag = (mSelectedTab == TAB_TICKETS) ? TAG_TICKETS : TAG_STATS;
    ProjectBaseFragment preInitializedFragment = (ProjectBaseFragment)getSupportFragmentManager()
        .findFragmentByTag(selectedTag);
    if (preInitializedFragment == null) {
        switch (mSelectedTab) {
            case TAB_TICKETS:
                mCurrentFragment = TicketsFragment.newInstance(getIntent().getLongExtra(EXTRA_TICKET_ID,
                    TicketsFragment.NONE), getIntent().getBooleanExtra(EXTRA_SHOW_SMS, false));
                break;
            case TAB_STATISTICS:
                mCurrentFragment = new StatisticsFragment();
                break;
        }
        ft.add(android.R.id.content, mCurrentFragment, selectedTag);
    } else {
        mCurrentFragment = preInitializedFragment;
        ft.attach(preInitializedFragment);
    }
}
 
Example 3
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
	Log.i(TAG, "onTabUnselected: " + tab.getPosition());

	ListFragment1 fragment = mSectionsPagerAdapter.getFragmentAt(tab.getPosition());
	if (null != fragment) {
		fragment.onVisibilityChanged(false);
	}
}
 
Example 4
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    if ( tab.getPosition() == 0 ){
        week_classtable.setVisibility(View.GONE);
        day_classtable_container.setVisibility(View.VISIBLE);
    } else if ( tab.getPosition() == 1 ) {
        week_classtable.setVisibility(View.VISIBLE);
        day_classtable_container.setVisibility(View.GONE);
    }
    // 储存用户当前选择的 Tab ;
    config.classTableSelectedTab().put(tab.getPosition());
}
 
Example 5
private void addLayoutTab(ActionBar actionBar, int layoutId, int iconId, String tag) {
    ActionBar.Tab tab = actionBar.newTab()
            .setText("")
            .setIcon(iconId)
            .setTabListener(new TabListener(layoutId, tag));
    actionBar.addTab(tab, layoutId == mSelectedLayoutId);
}
 
Example 6
Source Project: sms-ticket   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
    String selectedTag = (tab.getPosition() == TAB_TICKETS) ? TAG_TICKETS : TAG_STATS;
    ProjectBaseFragment preInitializedFragment = (ProjectBaseFragment)getSupportFragmentManager()
        .findFragmentByTag(selectedTag);
    if (preInitializedFragment != null) {
        ft.detach(preInitializedFragment);
    } else if (mCurrentFragment != null) {
        ft.detach(mCurrentFragment);
    }
}
 
Example 7
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // This is called when a tab is selected.
}
 
Example 8
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 9
@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 10
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // This is called when a previously selected tab is selected again.
}
 
Example 11
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
 
Example 12
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 13
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {}
 
Example 14
Source Project: PinView   File: MainActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    mViewPager.setCurrentItem(tab.getPosition());
}
 
Example 15
Source Project: vocefiscal-android   File: HomeActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) 
{
	//do nothing
}
 
Example 16
@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 17
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 18
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}
 
Example 19
Source Project: easy-adapter   File: MainActivity.java    License: Apache License 2.0 2 votes vote down vote up
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

        }
 
Example 20
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}