List of usage examples for android.app ActionBar NAVIGATION_MODE_TABS
int NAVIGATION_MODE_TABS
To view the source code for android.app ActionBar NAVIGATION_MODE_TABS.
Click Source Link
From source file:com.example.administrator.myapplication2._2_exercise._2_End._2_EndMain.java
/***************************************************** * Overrided methods// w w w . j ava2s . c o m ******************************************************/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //----- System, Context mContext = this; //.getApplicationContext(); mActivityHandler = new ActivityHandler(); AppSettings.initializeAppSettings(mContext); setContentView(R.layout._2_end_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the primary sections of the app. mFragmentManager = getSupportFragmentManager(); mSectionsPagerAdapter = new FragmentAdapter(mFragmentManager, mContext, this, mActivityHandler); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding tab. mViewPager.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++) { // Create a tab with text corresponding to the page title defined by the adapter. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.decad3nce.aegis.AegisActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager);//from w ww . j a v a 2 s. co m setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayShowHomeEnabled(true); bar.setHomeButtonEnabled(true); bar.setTitle(R.string.app_name); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.alarm_section), SMSAlarmFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.lock_section), SMSLockFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.wipe_section), SMSWipeFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.locate_section), SMSLocateFragment.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); alarmEnabled = preferences.getBoolean(PREFERENCES_ALARM_ENABLED, this.getResources().getBoolean(R.bool.config_default_alarm_enabled)); wipeEnabled = preferences.getBoolean(PREFERENCES_WIPE_ENABLED, this.getResources().getBoolean(R.bool.config_default_wipe_enabled)); lockEnabled = preferences.getBoolean(PREFERENCES_LOCK_ENABLED, this.getResources().getBoolean(R.bool.config_default_lock_enabled)); locateEnabled = preferences.getBoolean(PREFERENCES_LOCATE_ENABLED, this.getResources().getBoolean(R.bool.config_default_locate_enabled)); invalidateOptionsMenu(); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); }
From source file:org.digitalcampus.oppia.activity.ScorecardActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scorecard); actionBar = getActionBar();//from www . ja v a 2 s . co m viewPager = (ViewPager) findViewById(R.id.activity_scorecard_pager); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); prefs = PreferenceManager.getDefaultSharedPreferences(this); Bundle bundle = this.getIntent().getExtras(); if (bundle != null) { this.course = (Course) bundle.getSerializable(Course.TAG); this.targetTabOnLoad = bundle.getString(TAB_TARGET); } }
From source file:com.emotion.emotioncontrol.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDrawerEntries = getResources().getStringArray(R.array.navigation_drawer_entries); mDrawerValues = getResources().getStringArray(R.array.navigation_drawer_values); setContentView(R.layout.activity_main); mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle();//from w w w.j a va 2 s .c om // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); }
From source file:com.android.cts.uiautomator.Test4DetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { View rootView = inflater.inflate(R.layout.test4_detail_fragment, container, false); // Set up the action bar. final ActionBar actionBar = getActivity().getActionBar(); if (actionBar.getTabCount() > 0) { return rootView; }//from w w w. j av a 2s . c o m actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getActivity().getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) rootView.findViewById(R.id.test_4_detail_container); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have a // reference to the Tab. mViewPager.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++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the listener for when this tab is // selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } return rootView; }
From source file:com.example.llsdktest2.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //configuring SDK Setting.configureLimelightSettings("https://staging-api.lvp.llnw.net/rest", "https://staging-wlp.lvp.llnw.net/license", "limelight"); LoggerUtil.setLogLevelByString("Debug", this); Setting.SetAnalyticsEndPoint(//from ww w . j a v a2s . c om "https://staging-mcs.lvp.llnw.net/r/MetricsCollectionService/recordMetricsEvent"); setContentView(R.layout.activity_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOnPageChangeListener(this); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(2); actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(0)).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(1)).setTabListener(this)); }
From source file:com.jackie.effectiveNavigation.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar. actionBar = getActionBar();/*from w w w. java2 s. c o m*/ // ViewPager and its adapters use support library // fragments, so use getSupportFragmentManager. mAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager()); myViewPager = (ViewPager) findViewById(R.id.my_pager); myViewPager.setAdapter(mAdapter); myViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages. select the corresponding tab. getActionBar().setSelectedNavigationItem(position % 3); } }); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a tab listener that is called when the user changes tabs. ActionBar.TabListener tabListener = new ActionBar.TabListener() { /** * Called when a tab enters the selected state. * * @param tab The tab that was selected * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute * during a tab switch. The previous tab's unselect and this tab's select will be * executed in a single transaction. This FragmentTransaction does not support */ @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { // When the tab is selected, switch to the corresponding page in the ViewPager. int position = myViewPager.getCurrentItem(); int tabPosition = tab.getPosition(); int move = tabPosition - (position % 3); myViewPager.setCurrentItem(position + move); } /** * Called when a tab exits the selected state. * * @param tab The tab that was unselected * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute * during a tab switch. This tab's unselect and the newly selected tab's select * will be executed in a single transaction. This FragmentTransaction does not */ @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { } /** * Called when a tab that is already selected is chosen again by the user. * Some applications may use this action to return to the top level of a category. * * @param tab The tab that was reselected. * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute * once this method returns. This FragmentTransaction does not support */ @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } }; for (int i = 0; i < 3; i++) { actionBar.addTab(actionBar.newTab().setText("Tab " + (i + 1)).setTabListener(tabListener)); } }
From source file:com.example.ll.llsdktest.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //configuring SDK Setting.configureLimelightSettings("https://staging-api.lvp.llnw.net/rest", "https://staging-wlp.lvp.llnw.net/license", "limelight"); LoggerUtil.setLogLevelByString("Debug", this); Setting.SetAnalyticsEndPoint(//from w w w . java 2 s . c o m "https://staging-mcs.lvp.llnw.net/r/MetricsCollectionService/recordMetricsEvent"); setContentView(R.layout.activity_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOnPageChangeListener(this); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(2); actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(0)).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(1)).setTabListener(this)); }
From source file:com.tencent.stt.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppPagerAdapter = new AppPagerAdapter(getSupportFragmentManager()); // Set up the action bar. mActionBar = getActionBar();//from www. j a v a 2s . com // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. mActionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. mActionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. mActionBar.addTab(mActionBar.newTab().setText(mAppPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.microsoft.band.sdksample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* w w w .jav a 2 s . c o m*/ 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++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }