List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:vn.com.vng.phim123.HomeActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.//from www.java2 s . c om actionBar.setHomeButtonEnabled(true); // Specify that we will be displaying tabs in the action bar. actionBar.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(mAppSectionsPagerAdapter); 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. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.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(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.manoj.macawplayer.SwipeViewActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.drawable.theme_skyblue);//from ww w . j a va2s. c om requestWindowFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.swipe_view); int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); TextView actionBarTextView = (TextView) findViewById(actionBarTitleId); if (actionBarTextView != null) { Log.i("actionBarTextView :", "not null"); actionBarTextView.setTextColor(Color.GREEN); } else Log.i("actionBarTextView :", "null"); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //to remove the title and icon above the action bar getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowHomeEnabled(false); // 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); LinearLayout homeScreen = (LinearLayout) findViewById(R.id.swipeviewl); utilities = new Utilities(); utilities.colorSeter(homeScreen, getApplicationContext()); mViewPager.setAdapter(mAppSectionsPagerAdapter); 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. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.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(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); /*Tab tab = actionBar.getTabAt(i); View v = tab.setgetCustomView(); v.setBackgroundResource(R.drawable.theme_skyblue);*/ } }
From source file:com.example.oblivion.swippedui.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnNext = (ImageView) findViewById(R.id.a); btnPrev = (ImageView) findViewById(R.id.b); lblHeaderUserInApp = (TextView) findViewById(R.id.lblHeaderUserInApp); lblHeader1InApp = (TextView) findViewById(R.id.lblHeader1InApp); lblHeaderAgentInApp = (TextView) findViewById(R.id.lblHeaderAgentInApp); lblHeader2InApp = (TextView) findViewById(R.id.lblHeader2InApp); lblHeaderOutletInApp = (TextView) findViewById(R.id.lblHeaderOutletInApp); lblHeader3InApp = (TextView) findViewById(R.id.lblHeader3InApp); Typeface externalFont = Typeface.createFromAsset(getAssets(), "kalpurush.ttf"); lblHeaderUserInApp.setTypeface(externalFont); // lblHeader1InApp.setTypeface(externalFont); lblHeaderAgentInApp.setTypeface(externalFont); // lblHeader2InApp.setTypeface(externalFont); lblHeaderOutletInApp.setTypeface(externalFont); // lblHeader3InApp.setTypeface(externalFont); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./*www . j a v a 2s . co m*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.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(mAppSectionsPagerAdapter); 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. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.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(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } actionBar.hide(); btnNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1); } }); btnPrev.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1); } }); }
From source file:com.untappedkegg.rally.home.ActivityMain.java
void restoreActionBar() { ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(mActionBarDrawer[curPosition]); }//from www. j ava 2s . c om }
From source file:com.bignerdranch.android.fragmentbasics.NewsReaderActivity.java
/** Sets up Action Bar (if present). * * @param showTabs whether to show tabs (if false, will show list). * @param selTab the selected tab or list item. *//*from ww w. j ava 2 s. c o m*/ public void setUpActionBar(boolean showTabs, int selTab) { if (Build.VERSION.SDK_INT < 11) { // No action bar for you! // But do not despair. In this case the layout includes a bar across the // top that looks and feels like an action bar, but is made up of regular views. return; } android.app.ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); // Set up a CompatActionBarNavHandler to deliver us the Action Bar nagivation events CompatActionBarNavHandler handler = new CompatActionBarNavHandler(this); if (showTabs) { actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS); int i; for (i = 0; i < CATEGORIES.length; i++) { actionBar.addTab(actionBar.newTab().setText(CATEGORIES[i]).setTabListener(handler)); } actionBar.setSelectedNavigationItem(selTab); } else { actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); SpinnerAdapter adap = new ArrayAdapter<String>(this, R.layout.actionbar_list_item, CATEGORIES); actionBar.setListNavigationCallbacks(adap, handler); } // Show logo instead of icon+title. actionBar.setDisplayUseLogoEnabled(true); }
From source file:it.personal.keyring.SetupActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setup); // 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 app. 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/*from w w w. j a v a 2s. co 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)); } }
From source file:org.egokituz.arduino2android.activities.MainActivity.java
/** * Holder of the main tab/fragmen/section *///from w ww .j av a 2 s . c o m //private TestSectionFragment m_TestFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); m_ActivityContext = this; m_mainApp = (TestApplication) getApplication(); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. m_CustomPagerAdapter = new CustomPagerAdapter(getSupportFragmentManager(), m_ActivityContext, m_mainApp); /* // find the retained fragment on activity restarts m_TestFragment = (TestSectionFragment) m_CustomPagerAdapter.getItem(0); if(m_TestFragment == null){ m_TestFragment = new TestSectionFragment(); m_TestFragment.setArguments(m_ActivityContext, m_mainApp); m_CustomPagerAdapter.addItem(m_TestFragment, 0); }*/ // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. //actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.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(m_CustomPagerAdapter); 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. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < m_CustomPagerAdapter.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(m_CustomPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:uk.bowdlerize.MainActivity.java
private void configureTabs() { // 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(getFragmentManager()); // 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/*from w w w . j a va 2 s.c om*/ 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)); } }
From source file:com.example.jenil.parsedemo.GameShowActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_game_show_adapter); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./*from ww w . ja v a 2s .com*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.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.pagerShow); mViewPager.setAdapter(mAppSectionsPagerAdapter); 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. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.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(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.mac.SafeWalk.WelcomeActivity.java
/** * Called when the activity is first created. */// www . j a v a 2s. com @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome_screen); // Create adapter collectionPagerAdapter = new CollectionPagerAdapter(getSupportFragmentManager()); // Set up action bar. final ActionBar actionBar = getActionBar(); actionBar.hide(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager // Attache the adapter and implement listener in order to respond when user swipes between sections. viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(collectionPagerAdapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // Select the corresponding tab when user swipes actionBar.setSelectedNavigationItem(position); ImageView dot1 = (ImageView) findViewById(R.id.sliding_dot1); ImageView dot2 = (ImageView) findViewById(R.id.sliding_dot2); switch (position) { case 0: animate(dot1); break; case 1: animate(dot2); break; case 2: break; } } }); // For each of the sections, add tab to the action bar. for (int i = 0; i < collectionPagerAdapter.getCount(); i++) { // Create tabs actionBar.addTab(actionBar.newTab().setTabListener(this)); } Settings.getSettings().setContext(this); }