Example usage for android.app ActionBar setNavigationMode

List of usage examples for android.app ActionBar setNavigationMode

Introduction

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

Prototype

@Deprecated
public abstract void setNavigationMode(@NavigationMode int mode);

Source Link

Document

Set the current navigation mode.

Usage

From source file:com.lambdal.railgun.PInfo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set the activity
    PInfo.activity = this;
    int packageCount = PInfo.getPackages().size();

    // Hide the status bar.
    Window w = getWindow();//from   w w  w  . ja v a2  s . c om
    w.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    w.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    setContentView(R.layout.activity_main);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.hide();
    // getActionBar().setBackgroundDrawable(new
    // ColorDrawable(Color.argb(128, 0, 0, 0)));
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    mSectionsPagerAdapter.pageCount = packageCount;

    // 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
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    mViewPager.setOnClickListener(new ViewPager.OnClickListener() {
        @Override
        public void onClick(View view) {
            // When swiping between pages, select the
            // corresponding tab.
            int currentAppIndex = DummySectionFragment.currentAppIndex;
            ArrayList<PInfo> appList = PInfo.getInstalledApps(false);
            PInfo app = appList.get(currentSelectedTabIndex.intValue());
            // Open the app:
            Intent launchIntent = getPackageManager().getLaunchIntentForPackage(app.pname);
            try {
                startActivity(launchIntent);
            } catch (Exception e) {
                Log.v("We ran into an exception when launching intent: " + app.pname, e.toString());
            }
            Log.v("We have a tap event which happened at index: ",
                    app.toString() + " " + currentSelectedTabIndex.toString());
        }
    });

    for (int i = 0; i < PInfo.getPackages().size(); i++) {
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:net.seedboxer.seedroid.activities.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.main_activity_view);

    // 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 .  ja  v  a2  s  .com*/
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mViewPager = (ViewPager) findViewById(R.id.pager);

    mAppSectionsPagerAdapter = new TabsAdapter(this, getSupportFragmentManager(), mViewPager);
    mAppSectionsPagerAdapter.addTab(actionBar.newTab().setText(R.string.tab_title_inprogres),
            StatusFragment.class, null);
    mAppSectionsPagerAdapter.addTab(actionBar.newTab().setText(R.string.tab_title_queue), InQueueFragment.class,
            null);
    mAppSectionsPagerAdapter.addTab(actionBar.newTab().setText(R.string.tab_title_downloads),
            DownloadsFragment.class, null);

    if (savedInstanceState != null) {
        actionBar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }

    GCMRegistrar.checkManifest(this);
    GCMRegistrar.checkDevice(this);
}

From source file:org.openmidaas.app.activities.MainTabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_main_tab);

    //Get the text
    tabProfile = getResources().getString(R.string.profileTabtext);
    tabScan = getResources().getString(R.string.scanTabtext);
    tabInputURL = getResources().getString(R.string.urlTabtext);

    //Enabling action bar
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(null);//from   www  .  j a  v a  2  s. co m
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.show();
    getOverflowMenu();

    mActivity = this;
    mProgressDialog = new ProgressDialog(mActivity);

    mAttributeListFragment = new AttributeListFragment();
    mUrlInputFragment = new EnterURLDialogFragment();
    mScanFragment = new ScanFragment();

    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setOnTabChangedListener(listener);
    mTabHost.setup();
    mTabHost.getTabWidget().setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
    //initializing tabs
    initializeTab();
    //Check for updates
    checkForUpdates();
    //See if its being called to process URL from push message. 
    //MainAcivity not being killed to be consistent with what happens when the URL taken via QR code etc.
    if ((getIntent().getExtras() != null) && !getIntent().getExtras().isEmpty()) {
        if (getIntent().getAction().equals(Constants.IntentActionMessages.PROCESS_URL)) {
            processUrl(getIntent().getExtras().getString("url"));
        }
    }
}

From source file:com.shinobicontrols.transitions.StoryDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story_detail);

    if (savedInstanceState == null) {
        // Load the data from the intent on first pass
        Intent intent = getIntent();/*from   w  ww  .  j  a v a 2s  .  co  m*/
        String story_id = intent.getStringExtra(ARG_STORY_ID);
        mItem = StoryContent.STORY_MAP.get(story_id);
    }

    // Get hold of some relevant content
    final ViewGroup container = (ViewGroup) findViewById(R.id.container);

    // What are the layouts we should be able to transition between
    List<Integer> sceneLayouts = Arrays.asList(R.layout.content_scene_00, R.layout.content_scene_01,
            R.layout.content_scene_02);
    // Create the scenes
    sceneList = new ArrayList<Scene>();
    for (int layout : sceneLayouts) {
        // Create the scene
        Scene scene = Scene.getSceneForLayout(container, layout, this);
        // Just before the transition starts, ensure that the content has been loaded
        scene.setEnterAction(new Runnable() {
            @Override
            public void run() {
                addContentToViewGroup(container);
            }
        });
        // Save the scene into
        sceneList.add(scene);
    }

    // Build the transition manager
    TransitionInflater transitionInflater = TransitionInflater.from(this);
    mTransitionManager = transitionInflater.inflateTransitionManager(R.transition.story_transition_manager,
            container);

    // Show the Up button in the action bar.
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Specify we want some tabs
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // Create a listener to cope with tab changes
        ActionBar.TabListener tabListener = new ActionBar.TabListener() {
            @Override
            public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
                // If there's a scene for this tab index, then transition to it
                if (tab.getPosition() <= sceneList.size()) {
                    performTransitionToScene(sceneList.get(tab.getPosition()));
                }
            }

            @Override
            public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            @Override
            public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            private void performTransitionToScene(Scene scene) {
                mTransitionManager.transitionTo(scene);
            }
        };

        // Add some tabs
        for (int i = 0; i < sceneList.size(); i++) {
            actionBar.addTab(actionBar.newTab().setText("Scene " + i).setTabListener(tabListener));
        }
    }

    // Load the first scene
    sceneList.get(0).enter();
}

From source file:edu.pdx.cecs.orcycle.TabsConfig.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {/* w  w  w .j  a  va 2  s .  c  o  m*/
        myApp = MyApplication.getInstance();
        myApp.setRunning(true);
        myApp.clearReminderNotifications();

        setContentView(R.layout.tabs_config);

        Log.v(MODULE_TAG, "Cycle: TabsConfig onCreate");

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        // Toast.makeText(this, "Tab Created", Toast.LENGTH_LONG).show();

        fragment1 = new FragmentMainInput();
        fragment2 = new FragmentSavedTripsSection();
        fragment3 = new FragmentSavedNotesSection();
        //fragment4 = new FragmentUserInfo();
        fragment4 = new FragmentSettings();

        // Set up the action bar.
        final ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setBackgroundDrawable(getResources().getDrawable(R.color.psu_green));

        // Create the adapter that will return a fragment for each of the four
        // 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
            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));
        }

        mViewPager.setOffscreenPageLimit(4);

        Intent intent;
        Bundle bundle;
        if (null != (intent = getIntent())) {
            if (null != (bundle = intent.getExtras())) {
                fragmentToShow = bundle.getInt(TabsConfig.EXTRA_SHOW_FRAGMENT, FRAG_INDEX_MAIN_INPUT);
            }
        }
    } catch (Exception ex) {
        Log.e(MODULE_TAG, ex.getMessage());
    }
}

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

@SuppressWarnings("unchecked")
@Override/*from  w ww  .j ava 2  s.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.plnyyanks.frcnotebook.activities.ViewTeam.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceHandler.getTheme());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_team);

    activity = this;

    ActionBar bar = getActionBar();
    bar.setTitle(teamNumber != -1 ? "Team " + teamNumber : "All Data");

    //tab for team overview
    ActionBar.Tab teamOverviewTab = bar.newTab();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    teamOverviewTab.setText("All Notes");
    teamOverviewTab.setTag("all");
    teamOverviewTab.setTabListener(this);
    bar.addTab(teamOverviewTab);//from w  w w. ja v a2  s .  c  o m
    bar.setDisplayHomeAsUpEnabled(true);

    //add an actionbar tab for every event the team is competing at
    ArrayList<String> events;
    if (teamNumber == -1) {
        events = StartActivity.db.getAllEventKeys();
    } else {
        Team team = StartActivity.db.getTeam(teamKey);
        events = team.getTeamEvents();
    }
    for (String eventKey : events) {
        Log.d(Constants.LOG_TAG, "Making AB Tab for " + eventKey);
        Event event = StartActivity.db.getEvent(eventKey);
        if (event == null)
            continue;
        ActionBar.Tab eventTab = bar.newTab();
        eventTab.setTag(event.getEventKey());
        eventTab.setText(event.getShortName());
        eventTab.setTabListener(this);
        bar.addTab(eventTab);
    }

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM, 0));
    } else {
        bar.setSelectedNavigationItem(0);
    }

}

From source file:info.curtbinder.farmgame.GameActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);

    new PlayMusicBackground().execute();

    fieldValues = getResources().getIntArray(R.array.itemFieldValues);
    fieldTitles = getResources().getStringArray(R.array.itemTitles);
    fieldSubTitles = getResources().getStringArray(R.array.itemSubTitles);
    Bundle b = getIntent().getExtras();//from w ww . ja v  a2  s. c o m
    if (b != null) {
        gameId = b.getLong(GAMEID);
        gameDate = b.getString(GAMEDATE);
        gameName = b.getString(GAMENAME);
    }
    frags = new Fragment[MAX_FRAGS];

    // 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
        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));
    }

    setActivityTitle(gameName);

}

From source file:org.ounl.lifelonglearninghub.nfclearntracker.swipe.SwipeActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swipe);

    // 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 w w  w . j a v a  2 s  .  c o 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));
    }

}

From source file:com.networksaremadeofstring.anonionooid.RelayDetailsSwipe.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_relay_details_swipe);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mContext = this;
    if (null == lc)
        lc = new LocalCache(mContext);

    lc.open();//  w  w w. j av  a2  s . c om
    isFavourite = lc.isAFavourite(getIntent().getStringExtra(Ooo.ARG_ITEM_ID));
    lc.close();

    // Show the Up button in the action bar.
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setIcon(R.drawable.ab_icon);

    try {
        //fingerprint =
        actionBar.setSubtitle(getIntent().getStringExtra(Ooo.ARG_ITEM_ID));

    } catch (Exception e) {
        e.printStackTrace();
    }

    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        arguments = new Bundle();
        arguments.putString(Ooo.ARG_ITEM_ID, getIntent().getStringExtra(Ooo.ARG_ITEM_ID));

        /*RelayDetailFragment fragment = new RelayDetailFragment();
        fragment.setArguments(arguments);
        getFragmentManager().beginTransaction()
            .add(R.id.relay_detail_container, fragment)
            .commit();*/
    }

    // 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
        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));
    }
}