Example usage for android.app ActionBar DISPLAY_SHOW_HOME

List of usage examples for android.app ActionBar DISPLAY_SHOW_HOME

Introduction

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

Prototype

int DISPLAY_SHOW_HOME

To view the source code for android.app ActionBar DISPLAY_SHOW_HOME.

Click Source Link

Document

Show 'home' elements in this action bar, leaving more space for other navigation elements.

Usage

From source file:com.android.calendar.SearchActivity.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    dynamicTheme.onCreate(this);
    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);
    mHandler = new Handler();

    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);

    setContentView(R.layout.search);/*w ww. ja v  a2 s . c o m*/

    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    mContentResolver = getContentResolver();

    if (mIsMultipane) {
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
        }
    } else {
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayOptions(0,
                    ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
        }
    }

    // Must be the first to register because this activity can modify the
    // list of event handlers in it's handle method. This affects who the
    // rest of the handlers the controller dispatches to are.
    mController.registerEventHandler(HANDLER_KEY, this);

    mDeleteEventHelper = new DeleteEventHelper(this, this, false /* don't exit when done */);

    long millis = 0;
    if (icicle != null) {
        // Returns 0 if key not found
        millis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        if (DEBUG) {
            Log.v(TAG, "Restore value from icicle: " + millis);
        }
    }
    if (millis == 0) {
        // Didn't find a time in the bundle, look in intent or current time
        millis = Utils.timeFromIntentInMillis(getIntent());
    }

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query;
        if (icicle != null && icicle.containsKey(BUNDLE_KEY_RESTORE_SEARCH_QUERY)) {
            query = icicle.getString(BUNDLE_KEY_RESTORE_SEARCH_QUERY);
        } else {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if ("TARDIS".equalsIgnoreCase(query)) {
            Utils.tardis();
        }
        initFragments(millis, query);
    }
}

From source file:com.docd.purefm.ui.activities.SearchActivity.java

private void initActionBar() {
    //noinspection InflateParams
    final View actionBarCustom = this.getLayoutInflater().inflate(R.layout.activity_search_actionbar, null);
    if (actionBarCustom == null) {
        throw new RuntimeException("Inflated View is null");
    }/* w  w w  . j  a va  2  s.  c o  m*/

    final TextView path = (TextView) actionBarCustom.findViewById(android.R.id.text1);
    path.setText(mStartDirectory.getAbsolutePath());

    final ActionBar bar = this.getActionBar();
    if (bar == null) {
        throw new RuntimeException("ActionBar should not be null");
    }
    bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME
            | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
    bar.setCustomView(actionBarCustom);

    mActionModeController = new ActionModeController(this);
}

From source file:com.ternup.caddisfly.activity.SurveyActivity.java

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

    this.setTheme(((MainApp) getApplicationContext()).CurrentTheme);

    setContentView(R.layout.fragment_survey);

    // BEGIN_INCLUDE (inflate_set_custom_view)
    // Inflate a "Done/Cancel" custom action bar view.
    final LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext()
            .getSystemService(LAYOUT_INFLATER_SERVICE);
    final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done_cancel, null, false);

    final Context context = this;
    customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() {
        @Override/*w ww .  j  a  v  a  2 s . c om*/
        public void onClick(View v) {
            long locationId = saveData();
            if (locationId == -1) {
                mViewPager.setCurrentItem(1, true);
                AlertUtils.showMessage(context, R.string.incomplete, R.string.incompleteMessage);
            } else {
                Intent intent = new Intent();
                intent.putExtra(getString(R.string.currentLocationId), locationId);
                setResult(Activity.RESULT_OK, intent);
                //todo: change to finished method
                isCancelled = true;
                finish();
            }
        }
    });
    customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cancelSurvey();
        }
    });

    // Show the custom action bar view and hide the normal Home icon and title.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
            ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    // END_INCLUDE (inflate_set_custom_view)

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setOffscreenPageLimit(6);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            switch (position) {
            case 1:
                //mFormFragment.showKeyboard();
                break;
            case 4:
                mNotesFragment.showKeyboard();
                break;
            default:

                (new Handler()).postDelayed(new Runnable() {

                    public void run() {
                        ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                                .hideSoftInputFromWindow(mViewPager.getWindowToken(), 0);

                    }
                }, 300);
            }

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    // END_INCLUDE (setup_viewpager)

    // BEGIN_INCLUDE (setup_slidingTabLayout)
    // Give the SlidingTabLayout the ViewPager, this must be done AFTER the ViewPager has had
    // it's PagerAdapter set.
    /*
    A custom {@link android.support.v4.view.ViewPager} title strip which looks much like Tabs
    present in Android v4.0 and
    above, but is designed to give continuous feedback to the user when scrolling.
    */
    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    slidingTabLayout.setViewPager(mViewPager);

}

From source file:se.eliga.aves.birddetail.BirdDetailsTabActivity.java

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

    final String latinSpecies = getIntent().getExtras().getString(BirdListFragment.LATIN_SPECIES);
    final String englishSpecies = getIntent().getExtras().getString(BirdListFragment.ENGLISH_SPECIES);
    final String swedishFamily = getIntent().getExtras().getString(BirdListFragment.SWEDISH_FAMILY);

    Bundle bundle = new Bundle(1);
    bundle.putString(BirdSpeciesWebFragment.ENGLISH_SPECIES, englishSpecies);
    bundle.putString(BirdSpeciesXenoCantoPlayerFragment.LATIN_SPECIES, latinSpecies);

    tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    tabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);

    tabHost.addTab(/*from   w w w .  j  a  v  a 2  s .  c o m*/
            tabHost.newTabSpec("Wikipedia").setIndicator(getText(R.string.tab_wikipedia),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesWebFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Flickr").setIndicator(getText(R.string.tab_photos),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFlickrGalleryFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("xeno-canto").setIndicator(getText(R.string.tab_sounds),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesXenoCantoPlayerFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Statistik").setIndicator(getText(R.string.tab_facts),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFactsFragment.class, bundle);
    tabHost.addTab(tabHost.newTabSpec("Karta").setIndicator(getText(R.string.tab_map),
            getResources().getDrawable(android.R.drawable.star_on)), MapFragment.class, bundle);

    TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    LinearLayout linearLayout = (LinearLayout) tabWidget.getParent();
    HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
    horizontalScrollView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    linearLayout.addView(horizontalScrollView, 0);
    linearLayout.removeView(tabWidget);
    horizontalScrollView.addView(tabWidget);
    horizontalScrollView.setHorizontalScrollBarEnabled(false);

    BirdListSpinnerAdapter birdListSpinnerAdapter = createAdapter();
    birdListSpinnerAdapter.setFilterFamily(swedishFamily);
    birdListSpinnerAdapter.initialize(getSharedPreferences(Constants.BIRD_APP_SETTINGS, Context.MODE_PRIVATE));
    if (BirdListAdapter.SortOption.PHYLOGENETIC.equals(birdListSpinnerAdapter.getSortOption())) {
        birdListSpinnerAdapter.setSortOption(BirdListAdapter.SortOption.SWEDISH);
    }

    birdListSpinnerAdapter.refresh();
    birdListSpinnerAdapter.notifyDataSetChanged();

    Spinner spinner = new Spinner(this);
    spinner.setId(R.id.birdspecies_spinner);
    spinner.setAdapter(birdListSpinnerAdapter);
    spinner.setGravity(Gravity.FILL_HORIZONTAL);

    spinner.setSelection(birdListSpinnerAdapter.getPosition(new Bird(latinSpecies)));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            BirdSpeciesFragment fragment = (BirdSpeciesFragment) getSupportFragmentManager()
                    .findFragmentByTag(tabHost.getCurrentTabTag());
            Spinner spinner = (Spinner) getActionBar().getCustomView().findViewById(R.id.birdspecies_spinner);
            fragment.loadBird((Bird) spinner.getSelectedItem());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    getActionBar().setCustomView(spinner);
    getActionBar().setDisplayOptions(
            ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);

}

From source file:com.docd.purefm.ui.activities.BrowserPagerActivity.java

private void initActionBar() {
    mActionBar = this.getActionBar();
    if (mActionBar == null) {
        throw new RuntimeException("BrowserPagerActivity should have an ActionBar");
    }//from w w  w. ja  v a 2  s  .  co  m
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM
            | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP);

    //noinspection InflateParams
    final View custom = LayoutInflater.from(this).inflate(R.layout.activity_browser_actionbar, null);
    if (custom == null) {
        throw new RuntimeException("Inflated View is null");
    }
    mActionBar.setCustomView(custom);

    mBreadCrumbView = (BreadCrumbTextView) custom.findViewById(R.id.bread_crumb_view);
}

From source file:com.inha.stickyonpage.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (getSupportFragmentManager().findFragmentByTag("BrowsingWebView") != null) {
            if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT) || mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                mDrawerLayout.closeDrawer(Gravity.RIGHT);
                mDrawerLayout.closeDrawer(Gravity.LEFT);
                return false;
            } else {
                WebView mWebView = (WebView) findViewById(R.id.webView1);
                if (mWebView.canGoBack()) {
                    mWebView.goBack();//from ww  w .  jav a  2 s. c o m
                } else {
                    ActionBar mActionBar = getActionBar();
                    mActionBar.setCustomView(null);
                    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME);
                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    RecentStickyView stickyFragment = new RecentStickyView();
                    ft.replace(R.id.drawer_main, stickyFragment, "RecentStickyView");
                    ft.commit();
                }
                return false;
            }
        } else if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
            if (!mFlag) {
                Toast.makeText(this, "''?  ?  ?.",
                        Toast.LENGTH_SHORT).show();
                mFlag = true;
                mHandler.sendEmptyMessageDelayed(0, 2000);
                return false;
            } else {
                finish();
            }
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.theoreticsinc.schoolapp.activities.DrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_main);
    this.setTitle("School App");
    mTitle = mDrawerTitle = getTitle();//w  w w  .  java2s.co m

    settingsName = getResources().getStringArray(R.array.settings_array);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the items_list content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's listView view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, settingsName));
    LayoutInflater inflator = this.getLayoutInflater();
    View headerView = inflator.inflate(R.layout.imagedrawer, null);
    //View headerView = LayoutInflater.from(this).inflate(R.layout.imagedrawer, mDrawerLayout);
    //((TextView) headerView.findViewById(R.id.textView1)).setText("Angelo");
    //mDrawerList.addHeaderView(headerView);

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    /*
            // enable ActionBar app icon to behave as action to toggle nav drawer
            ActionBar mActionBar = getActionBar();
            mActionBar.setDisplayShowHomeEnabled(true);
            mActionBar.setDisplayShowTitleEnabled(true);
            LayoutInflater mInflater = LayoutInflater.from(this);
            
            //getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
            //getActionBar().setDisplayUseLogoEnabled(false);
            //getActionBar().setDisplayShowCustomEnabled(true);
            //getActionBar().setCustomView(R.layout.custom_actionbar);
            //getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
            
            View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
            mActionBar.setCustomView(mCustomView);
            mActionBar.setDisplayShowCustomEnabled(true);
    */

    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
    getActionBar().setCustomView(R.layout.custom_actionbar);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    mDrawerLayout.openDrawer(Gravity.LEFT);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.blank, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }

}

From source file:es.farfuteam.vncpp.controller.NewConnectionActivity.java

/**
 * @param savedInstanceState/*from  www . jav a  2  s.  com*/
 * @brief This is the onCreate method
 * @details The onCreate method adds buttons and edittext on the activity
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.connection_window);

    ConnectionName_field = (EditText) findViewById(R.id.ConnectionName_inserted);

    IP_field = (EditText) findViewById(R.id.IP_inserted);

    PORT_field = (EditText) findViewById(R.id.PORT_inserted);

    PSW_field = (EditText) findViewById(R.id.PSW_inserted);

    //desplegable seleccion de colores

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.color_array,
            android.R.layout.simple_spinner_item);

    Spinner_colors = (Spinner) findViewById(R.id.Spinner_colors);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    Spinner_colors.setAdapter(adapter);

    Spinner_colors.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, android.view.View v, int position, long id) {
            setColor_format(getPosEnumQuality(position));
        }

        public void onNothingSelected(AdapterView<?> parent) {
            //por defecto se selecciona la posicion 0, 24-bit color(extra-high)
            setColor_format(QualityArray.SuperHigh);
        }
    });

    Button botonConnect = (Button) findViewById(R.id.buttonConnect);
    botonConnect.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //primero se verifica que los campos se rellenan bien,
            //y se aade a la BD antes de iniciar Canvas.

            if (verify(v)) {

                //crear usuario si todo ha ido bien
                createNewConnection();

                iniCanvasActivity();

            }

        }
    });

    Button botonCancel = (Button) findViewById(R.id.buttonCancel);
    botonCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Cancel(v);

        }
    });

    //efectos del actionBar
    final ActionBar actionBar = getActionBar();

    actionBar.setDisplayOptions(
            ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);

}

From source file:com.xandy.calendar.EventInfoActivity.java

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

    // Get the info needed for the fragment
    Intent intent = getIntent();/*  w  w  w. ja va 2s .co m*/
    int attendeeResponse = 0;
    mEventId = -1;
    boolean isDialog = false;
    ArrayList<ReminderEntry> reminders = null;

    if (icicle != null) {
        mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID);
        mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS);
        mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS);
        attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE);
        isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG);

        reminders = Utils.readRemindersFromBundle(icicle);
    } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
        mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
        mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
        attendeeResponse = intent.getIntExtra(ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_NONE);
        Uri data = intent.getData();
        if (data != null) {
            try {
                List<String> pathSegments = data.getPathSegments();
                int size = pathSegments.size();
                if (size > 2 && "EventTime".equals(pathSegments.get(2))) {
                    // Support non-standard VIEW intent format:
                    //dat = content://com.android.calendar/events/[id]/EventTime/[start]/[end]
                    mEventId = Long.parseLong(pathSegments.get(1));
                    if (size > 4) {
                        mStartMillis = Long.parseLong(pathSegments.get(3));
                        mEndMillis = Long.parseLong(pathSegments.get(4));
                    }
                } else {
                    mEventId = Long.parseLong(data.getLastPathSegment());
                }
            } catch (NumberFormatException e) {
                if (mEventId == -1) {
                    // do nothing here , deal with it later
                } else if (mStartMillis == 0 || mEndMillis == 0) {
                    // Parsing failed on the start or end time , make sure the times were not
                    // pulled from the intent's extras and reset them.
                    mStartMillis = 0;
                    mEndMillis = 0;
                }
            }
        }
    }

    if (mEventId == -1) {
        Log.w(TAG, "No event id");
        Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show();
        finish();
    }

    // If we do not support showing full screen event info in this configuration,
    // close the activity and show the event in AllInOne.
    Resources res = getResources();
    if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen)
            && !res.getBoolean(R.bool.show_event_info_full_screen)) {
        CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis,
                attendeeResponse);
        finish();
        return;
    }

    setContentView(R.layout.simple_frame_layout);

    // Get the fragment if exists
    mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame);

    // Remove the application title
    ActionBar bar = getActionBar();
    if (bar != null) {
        bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
    }

    // Create a new fragment if none exists
    if (mInfoFragment == null) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse,
                isDialog,
                (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE),
                reminders);
        ft.replace(R.id.main_frame, mInfoFragment);
        ft.commit();
    }
}

From source file:com.numberx.kkmctimer.DeskClock.java

private void createTabs(int selectedIndex) {
    mActionBar = getActionBar();//from  w  ww  .ja  v  a  2 s  .co m

    if (mActionBar != null) {
        mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME);
        mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        mAlarmTab = mActionBar.newTab();
        mAlarmTab.setIcon(R.drawable.alarm_tab);
        mAlarmTab.setContentDescription(R.string.menu_alarm);
        mTabsAdapter.addTab(mAlarmTab, AlarmClockFragment.class, ALARM_TAB_INDEX);

        mClockTab = mActionBar.newTab();
        mClockTab.setIcon(R.drawable.clock_tab);
        mClockTab.setContentDescription(R.string.menu_clock);
        mTabsAdapter.addTab(mClockTab, ClockFragment.class, CLOCK_TAB_INDEX);

        mTimerTab = mActionBar.newTab();
        mTimerTab.setIcon(R.mipmap.ic_notification);
        mTimerTab.setContentDescription(R.string.menu_timer);
        mTabsAdapter.addTab(mTimerTab, TimerFragment.class, TIMER_TAB_INDEX);

        //mStopwatchTab = mActionBar.newTab();
        //mStopwatchTab.setIcon(R.drawable.stopwatch_tab);
        //mStopwatchTab.setContentDescription(R.string.menu_stopwatch);
        //mTabsAdapter.addTab(mStopwatchTab, StopwatchFragment.class,STOPWATCH_TAB_INDEX);

        mActionBar.setSelectedNavigationItem(selectedIndex);
        mTabsAdapter.notifySelectedPage(selectedIndex);

        forceTabsInActionBar(mActionBar);
    }
}