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

The following examples show how to use android.support.v7.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 sms-ticket with 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 2
Source File: AboutActivity.java    From Simple-Brick-Games with GNU General Public License v3.0 6 votes vote down vote up
@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 3
Source File: MainActivity.java    From sms-ticket with 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 4
Source File: TwoWayViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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 5
Source File: MainActivity2.java    From android-floating-action-menu with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: ClassTable.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
@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 7
Source File: MainActivity.java    From android-ActionBarCompat-Styled with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // This is called when a tab is selected.
}
 
Example 8
Source File: MainActivity.java    From android-IconicFontEngine with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 9
Source File: MainActivity.java    From android-IconicFontEngine with Apache License 2.0 4 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 10
Source File: HomeActivity.java    From vocefiscal-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) 
{
	//do nothing
}
 
Example 11
Source File: MainActivity.java    From PinView with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    mViewPager.setCurrentItem(tab.getPosition());
}
 
Example 12
Source File: AboutActivity.java    From Simple-Brick-Games with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {}
 
Example 13
Source File: MainActivity.java    From android-IconicFontEngine with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 14
Source File: TwoWayViewActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
 
Example 15
Source File: MainActivity.java    From android-ActionBarCompat-Styled with Apache License 2.0 4 votes vote down vote up
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // This is called when a previously selected tab is selected again.
}
 
Example 16
Source File: RecordViewActivity.java    From voice-pitch-analyzer with GNU Affero General Public License v3.0 4 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 17
Source File: MainFragment.java    From chromeadb_for_android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
 
Example 18
Source File: MainActivity.java    From easy-adapter with Apache License 2.0 2 votes vote down vote up
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

        }
 
Example 19
Source File: RecordViewActivity.java    From voice-pitch-analyzer with GNU Affero General Public License v3.0 2 votes vote down vote up
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}
 
Example 20
Source File: ClassTable.java    From iSCAU-Android with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}