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.digi.android.sample.xbeemanager.XBeeTabsActivity.java
/** * Configures the activity tabs of the action bar. *///from w w w.ja v a 2 s . c om private void configureTabs() { ActionBar actionBar = getActionBar(); if (actionBar == null) return; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); XBeeDeviceTabListener xbeeDeviceTabListener = new XBeeDeviceTabListener(); Tab infoTab = actionBar.newTab(); infoTab.setText(getResources().getString(R.string.device_info_fragment_title)); infoTab.setTabListener(xbeeDeviceTabListener); Tab discoverTab; discoverTab = actionBar.newTab(); discoverTab.setText(getResources().getString(R.string.device_discovery_fragment_title)); discoverTab.setTabListener(xbeeDeviceTabListener); Tab framesTab = actionBar.newTab(); framesTab.setText(getResources().getString(R.string.frames_fragment_title)); framesTab.setTabListener(xbeeDeviceTabListener); actionBar.addTab(infoTab); actionBar.addTab(discoverTab); actionBar.addTab(framesTab); }
From source file:com.denel.facepatrol.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mycontext = getApplicationContext(); // 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.// w ww . j a va 2 s . c om 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)); } }
From source file:com.github.hobbe.android.openkarotz.fragment.RadioFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(LOG_TAG, "onCreateView"); // Fetch the selected page number int index = getArguments().getInt(MainActivity.ARG_PAGE_NUMBER); // List of pages String[] pages = getResources().getStringArray(R.array.pages); // Page title String pageTitle = pages[index]; getActivity().setTitle(pageTitle);/*from w w w .j av a 2 s . c om*/ // Action bar tab navigation actionBar = getActivity().getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); View view = inflater.inflate(R.layout.page_radio, container, false); initializeView(view); Log.v(LOG_TAG, "onCreateView ... done"); return view; }
From source file:joshuatee.wx.WX.java
@Override protected void onCreate(Bundle savedInstanceState) { if (savedInstanceState != null) { savedInstanceState.remove("android:support:fragments"); }/*w ww . j av a 2s . c o m*/ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); preferences = PreferenceManager.getDefaultSharedPreferences(this); theme_blue_current = preferences.getString("THEME_BLUE", ""); setTheme(Utility.Theme(theme_blue_current)); setContentView(R.layout.main); simple_mode_current = preferences.getString("SIMPLE_MODE", ""); if (!DataStore.loaded) DataStore.Init(this); viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar(); mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); viewPager.setOffscreenPageLimit(4); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); if (simple_mode_current.startsWith("f")) { for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); } } else { for (String tab_name : tabs_simple) { actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); } } viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); refresh_dynamic_content(); }
From source file:co.nerdart.ourss.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); setContentView(activity_main);/* ww w . j a va 2 s .c om*/ // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Hack to always show the tabs under the actionbar try { Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class); setHasEmbeddedTabsMethod.setAccessible(true); setHasEmbeddedTabsMethod.invoke(actionBar, false); } catch (Exception ignored) { } // Create the adapter that will return a fragment for each of the three // primary sections of the app. /* * The {@link android.support.v4.view.PagerAdapter} that will provide fragments for each of the sections. We use a {@link * android.support.v4.app.FragmentPagerAdapter} derivative, which will keep every loaded fragment in memory. If this becomes too memory * intensive, it may be best to switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}. */ SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(id.pager); mViewPager.setAdapter(sectionsPagerAdapter); // 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); invalidateOptionsMenu(); // Do not do it into onTabSelected()! } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < sectionsPagerAdapter.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(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } if (PrefUtils.getBoolean(PrefUtils.REFRESH_ENABLED, true)) { // starts the service independent to this activity startService(new Intent(this, RefreshService.class)); } else { stopService(new Intent(this, RefreshService.class)); } if (PrefUtils.getBoolean(PrefUtils.REFRESH_ON_OPEN_ENABLED, false)) { if (!FetcherService.isRefreshingFeeds) { startService(new Intent(MainActivity.this, FetcherService.class) .setAction(Constants.ACTION_REFRESH_FEEDS)); } } getSupportLoaderManager().initLoader(loaderId, null, this); }
From source file:com.example.android.foodstorm.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dataSource = new FoodSQLiteHelper(this); // 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(); actionBar.setHomeButtonEnabled(false); // no home/up button 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//from w w w.ja va2s . c om public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.fridge_main).setTabListener(this)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.chef_hat).setTabListener(this)); }
From source file:app.hacked.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); //getActionBar().setIcon(R.drawable.ic_ab_logo); actionBar.setSubtitle("This app is UNOFFICIAL"); queue = Volley.newRequestQueue(this); // 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// w ww . j a va 2 s . com 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)); } //GCM stuff GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { Log.v("GCM", "Registering"); GCMRegistrar.register(this, API.SENDER_ID); } else { Log.v("GCM", "Already registered"); } //Log.e("GCMID",GCMRegistrar.getRegistrationId(this)); JSONObject post = new JSONObject(); try { post.put("gcmid", regId); post.put("deviceid", Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID)); } catch (Exception e) { e.printStackTrace(); Toast.makeText(this, "An Error Was encountered connecting to the GCM cloud. Chat will be unavailable", Toast.LENGTH_LONG).show(); return; } JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST, "http://hackedioapp.networksaremadeofstring.co.uk/registergcm.php", post, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.e("response", response.toString()); try { if (response.has("success") && response.getBoolean("success")) { //Alls cool } } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub } }); queue.add(jsObjRequest); }
From source file:com.richtodd.android.quiltdesign.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.setDefaultValues(this, R.xml.application_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.block_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.quilt_preferences, false); setContentView(R.layout.activity_main); FragmentManager fm = getFragmentManager(); m_pagerAdapter = new HomeCollectionPagerAdapter(fm); m_viewPager = (ViewPager) findViewById(R.id.viewPager); m_viewPager.setAdapter(m_pagerAdapter); m_viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override/*from w w w . j a v a 2 s . co m*/ public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } }); m_actionBar = getActionBar(); m_actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.TabListener actionBarTabListener = new TabListener() { @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { m_viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { } }; m_actionBar.addTab(m_actionBar.newTab().setText("Blocks").setTabListener(actionBarTabListener)); m_actionBar.addTab(m_actionBar.newTab().setText("Quilts").setTabListener(actionBarTabListener)); m_actionBar.addTab(m_actionBar.newTab().setText("Themes").setTabListener(actionBarTabListener)); }
From source file:com.groksolutions.grok.mobile.HourDayWeekActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getResourceView());/*from ww w . j a va 2s .com*/ // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); Locale l = Locale.getDefault(); // For each of the sections in the app, add a tab to the action bar. // Add the "Fragment" class to the tab's tag. The tab's "Fragment" will // be created using this class // Hour Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_hour).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Hour)); // Day Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_day).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Day)); // Week Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_week).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Week)); // Create the fragment adapter that will return a fragment based on the // Fragment class attached to the tab's tag object final FragmentPagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { final Fragment[] _fragments = new Fragment[3]; @Override public Fragment getItem(int position) { Tab tab = actionBar.getTabAt(position); if (tab != null) { if (_fragments[position] == null) { _fragments[position] = createTabFragment(tab); } } return _fragments[position]; } @Override public int getCount() { return actionBar.getTabCount(); } }; // Set up the ViewPager with the sections adapter. _viewPager = (ViewPager) findViewById(R.id.pager); _viewPager.setAdapter(pagerAdapter); // Keep all pages in memory _viewPager.setOffscreenPageLimit(2); // 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. _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); }
From source file:pl.bcichecki.rms.client.android.activities.MessagingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_messaging); actionBar = getActionBar();//from w w w . j a va 2 s. c o m actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); messagingActivityActionBarTabListener = new MessagingActivityActionBarTabListener(viewPager); for (int i = 0; i < sectionsPagerAdapter.getCount(); i++) { Tab tab = actionBar.newTab(); tab.setText(sectionsPagerAdapter.getPageTitle(i)); tab.setTabListener(messagingActivityActionBarTabListener); actionBar.addTab(tab); } }