Example usage for android.app ActionBar newTab

List of usage examples for android.app ActionBar newTab

Introduction

In this page you can find the example usage for android.app ActionBar newTab.

Prototype

@Deprecated
public abstract Tab newTab();

Source Link

Document

Create and return a new Tab .

Usage

From source file:org.birthdayadapter.ui.BaseActivity.java

/**
 * Called when the activity is first created.
 *//*from  w  ww . j av  a 2 s. c  o m*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mActivity = this;

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // Load Activity for Android < 4.0
        Intent oldActivity = new Intent(mActivity, BaseActivityV8.class);
        oldActivity.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(oldActivity);
        finish();
    } else {
        // Load new design with tabs
        mViewPager = new ViewPager(this);
        mViewPager.setId(R.id.pager);

        setContentView(mViewPager);

        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(false);

        mTabsAdapter = new TabsAdapter(this, mViewPager);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_main)), BaseFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_preferences)),
                PreferencesFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_accounts)),
                AccountListFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_help)), HelpFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_about)), AboutFragment.class,
                null);

        // default is disabled:
        mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE);

        mySharedPreferenceChangeListener = new MySharedPreferenceChangeListener(mActivity,
                mBackgroundStatusHandler);

        /*
         * Show workaround dialog for Android bug http://code.google.com/p/android/issues/detail?id=34880
         * Bug exists on Android 4.1 (SDK 16) and on some phones like Galaxy S4
         */
        if (BuildConfig.GOOGLE_PLAY_VERSION && PreferencesHelper.getShowWorkaroundDialog(mActivity)
                && !isPackageInstalled("org.birthdayadapter.jb.workaround")) {
            if ((Build.VERSION.SDK_INT == 16) || Build.DEVICE.toUpperCase().startsWith("GT-I9000")
                    || Build.DEVICE.toUpperCase().startsWith("GT-I9500")) {
                InstallWorkaroundDialogFragment dialog = InstallWorkaroundDialogFragment.newInstance();
                dialog.show(getFragmentManager(), "workaroundDialog");
            }
        }
    }
}

From source file:com.michellgaby.advsettings.DeviceSettings.java

@TargetApi(11)
@Override/*from   ww  w.  j a va2s.  c om*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.viewPager);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);

    // Remove title and icon
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.general_settings_title), GeneralSettings.class, null);
    /**
     * mTabsAdapter.addTab(
     * bar.newTab().setText(R.string.category_mdnie_title),
     * mDNIeFragmentActivity.class, null); mTabsAdapter.addTab(
     * bar.newTab().setText(R.string.category_sensors_title),
     * SensorsFragmentActivity.class, null);
     */

    mTabsAdapter.addTab(bar.newTab().setText(R.string.system_settings_title), SystemSettings.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.j  a  v a 2 s.co m*/
}

From source file:com.kosbrother.houseprice.ActionBarTabs.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.action_bar_tabs);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // actionBar.setDisplayShowTitleEnabled(false);
    if (Build.VERSION.SDK_INT >= 14) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }//from   www  . ja v  a  2 s  . c  o m
    actionBar.addTab(actionBar.newTab().setText("")
            .setTabListener(new TabListener("http://m.yungching.com.tw/", "YungChing")));
    actionBar.addTab(actionBar.newTab().setText("")
            .setTabListener(new TabListener("http://m.sinyi.com.tw/", "SinYi")));
    actionBar.addTab(actionBar.newTab().setText("591")
            .setTabListener(new TabListener("http://m.591.com.tw/mobile-index.html?f=app", "591")));
    CallAds();

}

From source file:com.aniruddhc.acemusic.player.MusicLibraryEditorActivity.MusicLibraryEditorActivity.java

@SuppressWarnings("unchecked")
@Override//from w  w w.  j a v a2s .  c  om
public void onCreate(Bundle savedInstanceState) {

    //Initialize Context and SharedPreferences.
    mContext = this;
    mApp = (Common) mContext.getApplicationContext();

    //Retrieve the name/icon of the library from the arguments.
    libraryName = getIntent().getExtras().getString("LIBRARY_NAME");
    libraryIconName = getIntent().getExtras().getString("LIBRARY_ICON");

    if (getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET") != null) {
        songDBIdsList = (HashSet<String>) getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET");
    }

    //Set the UI theme.
    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
        setTheme(R.style.AppTheme);
    } else {
        setTheme(R.style.AppThemeLight);
    }
    super.onCreate(savedInstanceState);

    //Initialize the database helper.
    dbHelper = new DBAccessHelper(mContext.getApplicationContext());

    //Create a set of options to optimize the bitmap memory usage.
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    options.inJustDecodeBounds = false;
    options.inPurgeable = true;

    //Display Image Options.
    int defaultArt = UIElementsHelper.getIcon(mContext, "default_album_art_padded");
    displayImageOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.default_album_art)
            .showImageOnFail(R.drawable.default_album_art).showStubImage(R.drawable.transparent_drawable)
            .cacheInMemory(false).cacheOnDisc(true).decodingOptions(options)
            .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565)
            .displayer(new FadeInBitmapDisplayer(400)).delayBeforeLoading(100).build();

    //Attach tabs to the ActionBar.
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    //Add the artists tab.
    String artistsLabel = getResources().getString(R.string.artists);
    Tab tab = actionBar.newTab();
    tab.setText(artistsLabel);
    TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this,
            artistsLabel, ArtistsPickerFragment.class);

    tab.setTabListener(artistsTabListener);
    actionBar.addTab(tab);

    //Add the albums tab.
    String albumsLabel = getResources().getString(R.string.albums);
    tab = actionBar.newTab();
    tab.setText(albumsLabel);
    TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this,
            albumsLabel, AlbumsPickerFragment.class);

    tab.setTabListener(albumsTabListener);
    actionBar.addTab(tab);

    //Add the songs tab.
    String songsLabel = getResources().getString(R.string.songs);
    tab = actionBar.newTab();
    tab.setText(songsLabel);
    TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel,
            SongsPickerFragment.class);

    tab.setTabListener(songsTabListener);
    actionBar.addTab(tab);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(mContext));
        int topPadding = Common.getStatusBarHeight(mContext);
        View activityView = (View) findViewById(android.R.id.content);

        //Calculate ActionBar height
        TypedValue tv = new TypedValue();
        int actionBarHeight = 0;
        if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
                    getResources().getDisplayMetrics());
        }

        if (activityView != null) {
            activityView.setPadding(0, topPadding + actionBarHeight, 0, 0);
        }

    }

}

From source file:com.raypold.raypoldcounter.MainActivity.java

@Override
protected void onCreate(Bundle arg0) {

    super.onCreate(arg0);
    setContentView(R.layout.activity_main);

    context = getApplicationContext();//from  www.jav a  2 s . c  o m
    setFragmentManager();
    detectFirstRun();

    /*
     * Open the sharedPreference files for the actionBar functions extended
     * in ActionBarHandler
     */
    preferences = getSharedPreferences("userPreferences", 0);
    savedCounters = getSharedPreferences("savedCounters", 0);

    /* Create the action bar */
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager()));

    setTabNames();

    /* Create the navigation tabs and add them to the action bar */
    for (String tabName : tabNames) {
        actionBar.addTab(actionBar.newTab().setText(tabName).setTabListener(this));
    }

    /* Synchronize the the swiping and the highlighted tab view */
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int arg0) {
            actionBar.setSelectedNavigationItem(arg0);
        }
    });
}

From source file:run.ace.TabBar.java

public void show(android.app.Activity activity) {
    //if (!(activity instanceof ActionBarActivity)) {
    android.app.ActionBar mainActionBar = activity.getActionBar();
    if (mainActionBar != null) {
        mainActionBar.show();/*from www.j  av a  2  s .co  m*/
        mainActionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
        if (_primaryCommands != null) {
            for (int i = 0; i < _primaryCommands.size(); i++) {
                android.app.ActionBar.Tab tab = mainActionBar.newTab();
                AppBarButton abb = (AppBarButton) _primaryCommands.get(i);
                if (abb.icon != null) {
                    tab.setCustomView(getCustomTabView(abb, mainActionBar.getThemedContext()));
                } else {
                    tab.setText(abb.label);
                }
                tab.setTabListener(this);
                mainActionBar.addTab(tab, i == 0);
            }
        }
        return;
    }
    throw new RuntimeException(
            "Cannot use TabBar on the main page in Android unless you set <preference name=\"ShowTitle\" value=\"true\"/> in config.xml.");
    //}
    //else {
    //    ActionBar actionBar = ((ActionBarActivity)activity).getSupportActionBar();
    //    if (actionBar != null) {
    //        actionBar.show();
    //        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //        for (int i = 0; i < _primaryCommands.size(); i++) {
    //            ActionBar.Tab tab = actionBar.newTab();
    //            AppBarButton abb = (AppBarButton)_primaryCommands.get(i);
    //            if (abb.icon != null) {
    //                tab.setCustomView(getCustomTabView(abb, actionBar.getThemedContext()));
    //            }
    //            else {
    //                tab.setText(abb.label);
    //            }
    //            tab.setTabListener(this);
    //            actionBar.addTab(tab);
    //        }
    //        return;
    //    }
    //    throw new RuntimeException(
    //        "Unable to get TabBar from the current activity.");
    //}
}

From source file:com.android.xbrowser.ComboViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);/*  w  w w  .  ja va  2 s.c  om*/
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_snapshots), BrowserSnapshotPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}

From source file:com.actionbarsherlock.sample.styled.MainActivityICS.java

/** Called when the activity is first created. */
@Override//from  w w w  .j  av  a  2 s. co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_PROGRESS);

    setContentView(R.layout.main);
    final ActionBar ab = getActionBar();

    // set defaults for logo & home up
    ab.setDisplayHomeAsUpEnabled(showHomeUp);
    ab.setDisplayUseLogoEnabled(useLogo);

    // set up tabs nav
    for (int i = 1; i < 4; i++) {
        ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this));
    }

    // set up list nav
    ab.setListNavigationCallbacks(
            ArrayAdapter.createFromResource(ab.getThemedContext(), R.array.sections,
                    android.R.layout.simple_spinner_dropdown_item),
            //              .createFromResource(this, R.array.sections,
            //                      android.R.layout.simple_spinner_dropdown_item),
            new OnNavigationListener() {
                @Override
                public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                    // FIXME add proper implementation
                    //rotateLeftFrag();
                    return false;
                }
            });

    // default to tab navigation
    showTabsNav();

    // create a couple of simple fragments as placeholders
    //        final int MARGIN = 16;
    //        leftFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN);
    //        rightFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN,
    //                MARGIN);
    //
    //        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    //        ft.add(R.id.root, leftFrag);
    //        ft.add(R.id.root, rightFrag);
    //        ft.commit();

    ((Button) findViewById(R.id.start)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMode = startActionMode(new AnActionModeOfEpicProportions());
        }
    });
    ((Button) findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMode != null) {
                mMode.finish();
            }
        }
    });

    ((Button) findViewById(R.id.progress)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mProgress == 100) {
                mProgress = 0;
                mProgressRunner.run();
            }
        }
    });

}

From source file:com.ape.filemanager.FileExplorerTabActivityOld.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);

    mIsMyOsOptionMenuStyle = getResources().getBoolean(R.bool.myos_option_menu_style);

    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), FileCategoryActivityMyOS.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null);
    if (getResources().getBoolean(R.bool.have_cloud_file)) {
        mTabsAdapter.addTab(bar.newTab().setText(R.string.cloud_storage), CloudFileActivity.class, null);
    } else {//  ww  w  .  j a  v  a 2s. c om
        mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null);
    }

    int tabIndex;
    Intent intent = getIntent();
    String action = intent.getAction();
    if (getIntent().getData() != null) {
        tabIndex = Util.SDCARD_TAB_INDEX;
    } else if (!TextUtils.isEmpty(action)) {
        if (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT)
                || action.equals("com.mediatek.filemanager.ADD_FILE")) {
            tabIndex = Util.CATEGORY_TAB_INDEX;
        } else if (action.equals(CloudFileUtil.CLOUD_STORAGE_ACTION)) {
            tabIndex = Util.REMOTE_TAB_INDEX;
        } else {
            tabIndex = Util.CATEGORY_TAB_INDEX;
        }
    } else {
        tabIndex = Util.CATEGORY_TAB_INDEX; //For market require.
        //          tabIndex = PreferenceManager.getDefaultSharedPreferences(this)
        //                  .getInt(INSTANCESTATE_TAB, Util.CATEGORY_TAB_INDEX);
    }
    bar.setSelectedNavigationItem(tabIndex);

    mMountPointManager = MountPointManager.getInstance();
    mMountPointManager.init(this);
}