List of usage examples for android.app ActionBar setSelectedNavigationItem
@Deprecated public abstract void setSelectedNavigationItem(int position);
From source file:com.little.ibooks.file.FileExplorerTabActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.file_fragment_pager); mViewPager = (ViewPager) findViewById(R.id.pager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(INSTANCESTATE_TAB, 0)); }//from w ww .ja v a 2 s .c o m // ?"WIFI" Intent intent = getIntent(); if (intent != null) { String fileMode = intent.getStringExtra("mode"); if (fileMode != null && "wifi".equals(fileMode)) { mViewPager.setCurrentItem(1); } } }
From source file:com.blueoxfords.peacecorpstinder.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); activity = this; mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(this, getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(2); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(false); actionBar.setTitle(getString(R.string.app_name)); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* w w w .ja va 2 s.c o m*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this)); } } }
From source file:com.example.android.supportv13.app.ActionBarTabsPager.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager);/*from ww w .j ava 2 s . co m*/ setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText("Simple"), CountingFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText("List"), FragmentPagerSupport.ArrayListFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText("Cursor"), CursorFragment.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } }
From source file:com.geenk.fileexplorer.FileExplorerTabActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.fragment_pager); mViewPager = (ViewPager) findViewById(R.id.pager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME); mTabsAdapter = new TabsAdapter(this, mViewPager); // mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), // FileViewActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(INSTANCESTATE_TAB, 0)); }//w ww . ja v a 2 s . co m }
From source file:ru.lizaalert.hotline.ui.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(); assert actionBar != null; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mSectionsPagerAdapter = new SectionsPagerAdapter(this, getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override//from www. j av a 2s. c o m public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); if (position == 1) { if (getCurrentFocus() != null) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } } } }); for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:org.ado.minesync.gui.MineSyncMainActivity.java
/** * Called when the activity is first created. * * @param savedInstanceState If the activity is being re-initialized after * previously being shut down then this Bundle contains the data it most * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b> *///from w w w.j a v a2 s . c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ALog.d(TAG, "onCreate. savedInstanceState [" + savedInstanceState + "]."); setContentView(R.layout.activity_main); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getApplicationContext(), getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } accountManager = getDropboxAccountManager(getApplicationContext()); activityTracker = new ActivityTracker(getApplicationContext()); minecraftDropboxStatus = new MinecraftDropboxStatus(this); upgradeManager = new UpgradeManager(getApplicationContext()); upgradeManager.upgradeIfNeeded(); startServicesIfNeeded(); ALog.d(TAG, "var configProcessActive [" + configProcessActive + "]"); }
From source file:net.sf.diningout.app.ui.RestaurantsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar ab = getActionBar(); ab.setDisplayShowTitleEnabled(false); ab.setNavigationMode(NAVIGATION_MODE_LIST); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.restaurants_navigation, R.id.sort, res().getStringArray(R.array.restaurants_sort)); adapter.setDropDownViewResource(R.layout.restaurants_navigation_item); ab.setListNavigationCallbacks(adapter, this); ab.setSelectedNavigationItem(mSort); // restore when rotating with navigation drawer open setContentView(R.layout.restaurants_activity); if (mDrawerLayout != null) { setDrawerLayout(mDrawerLayout);/*w w w .j av a2 s . co m*/ } /* set up the map if it was previously showing */ MapFragment map = map(); if (map != null) { map.getMapAsync(this); } getLoaderManager().initLoader(0, null, this); // need already to support config changes }
From source file:ti.android.ble.devicemonitor.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(mResourceFragmentPager); // Set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ImageView view = (ImageView) findViewById(android.R.id.home); view.setPadding(10, 0, 20, 10);// w w w.j a v a 2 s . c o m // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(mResourceIdPager); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int n) { Log.d(TAG, "onPageSelected: " + n); actionBar.setSelectedNavigationItem(n); } }); // Create the adapter that will return a fragment for each section mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager.setAdapter(mSectionsPagerAdapter); }
From source file:com.evervolv.toolbox2.Toolbox.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager);//from ww w. j a v a 2s . c o m setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayHomeAsUpEnabled(true); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.interface_title), Interface.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.performance_title), Performance.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.updates_title), Updates.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } }
From source file:id.ridon.fileexplorer.FileExplorerTabActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_pager); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGES); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_category), FileCategoryActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null); bar.setSelectedNavigationItem(PreferenceManager.getDefaultSharedPreferences(this).getInt(INSTANCESTATE_TAB, Util.CATEGORY_TAB_INDEX)); }