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

The following are Jave code examples for showing how to use Tab of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Simple-Search   File: AboutActivity.java   Source Code and License Vote up 6 votes
@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
Project: zabbkit-android   File: TabListener.java   Source Code and License Vote up 5 votes
@Override
public void onTabSelected(ActionBar.Tab tab, android.support.v4.app.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());
        mFragment.setRetainInstance(true);
        ft.add(R.id.fragment_content, mFragment, mTag);
    } else {
        // If it exists and not attached, simply attach it in order to
        // show it
        ft.attach(mFragment);
    }
}
 
Example 3
Project: zabbkit-android   File: TabListener.java   Source Code and License Vote up 5 votes
@Override
public void onTabUnselected(ActionBar.Tab tab, android.support.v4.app.FragmentTransaction ft) {
    if (mFragment != null) {
        // Detach the fragment, because another one is being attached
        ft.detach(mFragment);
    }
}
 
Example 4
Project: GitHub   File: ViewPagerChartsActivity.java   Source Code and License Vote up 4 votes
@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 5
Project: GitHub   File: ViewPagerChartsActivity.java   Source Code and License Vote up 4 votes
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 6
Project: GitHub   File: ViewPagerChartsActivity.java   Source Code and License Vote up 4 votes
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 7
Project: GitHub   File: ThreadExampleActivity.java   Source Code and License Vote up 4 votes
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    viewPager.setCurrentItem(tab.getPosition());
}
 
Example 8
Project: Simple-Search   File: AboutActivity.java   Source Code and License Vote up 4 votes
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {}
 
Example 9
Project: Simple-Search   File: AboutActivity.java   Source Code and License Vote up 4 votes
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {}
 
Example 10
Project: GitHub   File: ThreadExampleActivity.java   Source Code and License Vote up 2 votes
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}
 
Example 11
Project: GitHub   File: ThreadExampleActivity.java   Source Code and License Vote up 2 votes
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}
 
Example 12
Project: zabbkit-android   File: TabListener.java   Source Code and License Vote up 2 votes
@Override
public void onTabReselected(ActionBar.Tab tab, android.support.v4.app.FragmentTransaction ft) {

}