Example usage for android.app ActionBar DISPLAY_SHOW_TITLE

List of usage examples for android.app ActionBar DISPLAY_SHOW_TITLE

Introduction

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

Prototype

int DISPLAY_SHOW_TITLE

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

Click Source Link

Document

Show the activity title and subtitle, if present.

Usage

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

@Override
public void setDisplayOptions(int newOpts) {
    final int oldOpts = mDisplayOpts;
    final int changed = oldOpts ^ newOpts;
    mDisplayOpts = newOpts;//w  w  w  . j  av  a 2s. c  o m
    if (changed != 0) {
        if ((changed & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            if ((newOpts & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
                updateNavigationIcon();
                updateHomeAccessibility();
            } else {
                mToolbar.setNavigationIcon(null);
            }
        }

        if ((changed & AFFECTS_LOGO_MASK) != 0) {
            updateToolbarLogo();
        }

        if ((changed & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
            if ((newOpts & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
                mToolbar.setTitle(mTitle);
                mToolbar.setSubtitle(mSubtitle);
            } else {
                mToolbar.setTitle(null);
                mToolbar.setSubtitle(null);
            }
        }

        if ((changed & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomView != null) {
            if ((newOpts & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                mToolbar.addView(mCustomView);
            } else {
                mToolbar.removeView(mCustomView);
            }
        }
    }
}

From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java

/**
 * Show a custom action bar in the activity.
 * @param inflater Inflater used to create the widgets.
 *///from   w ww .j  a va  2  s .  c om
private void createActionBar(LayoutInflater inflater) {
    final View customActionBarView = inflater.inflate(R.layout.actionbar_done_cancel, null);
    customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Done.
            //Toast.makeText(getActivity(), R.string.accept, Toast.LENGTH_SHORT).show();

            Movement cashMovement = new Movement();
            cashMovement.setAmount(getInputAmount());
            cashMovement.setDate(new Date(getInputDate()));
            cashMovement.setDescription(getInputNotes());

            if (mIsNegative) {
                cashMovement.setSing("-");
            } else {
                cashMovement.setSing("+");
            }

            cashMovement.setIdAccount(mAccountsSpinner.getSelectedItemId());

            mCashState.saveCashMovement(cashMovement);
            Toast.makeText(getActivity(), R.string.movement_save_message, Toast.LENGTH_SHORT).show();

            Intent intent = new Intent();
            // Indicate to parent activity that the information was store.
            intent.putExtra(MainActivity.ADD_MOVEMENT_RESULT, true);
            getActivity().setResult(MainActivity.REQUEST_CODE, intent);
            getActivity().finish();
        }
    });

    customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Cancel
            getActivity().finish();
        }
    });

    final ActionBar actionBar = getActivity().getActionBar();

    if (actionBar != null) {
        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));
    }
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.widget.ListWidgetConfig.java

void setupActionBar() {
    final WidgetPrefs widgetPrefs = new WidgetPrefs(this, appWidgetId);

    LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext()
            .getSystemService(LAYOUT_INFLATER_SERVICE);
    final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done, null);
    customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() {
        @Override//w w  w . j a  v  a  2  s.com
        public void onClick(View v) {
            // "Done"
            // // Set success
            widgetPrefs.setPresent();
            Intent resultValue = new Intent();
            resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            setResult(RESULT_OK, resultValue);
            // Build/Update widget
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
            // Log.d(TAG, "finishing WidgetId " + appWidgetId);
            appWidgetManager.updateAppWidget(appWidgetId, ListWidgetProvider
                    .buildRemoteViews(getApplicationContext(), appWidgetManager, appWidgetId, widgetPrefs));
            // Update list items
            appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.notesList);
            // Destroy activity
            finish();
        }
    });
    // 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);
}

From source file:com.android.ex.photo.PhotoViewActivity.java

/**
 * Adjusts the activity title and subtitle to reflect the photo name and count.
 *//*from  w  ww.  j  a  v a  2s  .co m*/
protected void updateActionBar(PhotoViewFragment fragment) {
    final int position = mViewPager.getCurrentItem() + 1;
    final String title;
    final String subtitle;
    final boolean hasAlbumCount = mAlbumCount >= 0;

    final Cursor cursor = getCursorAtProperPosition();

    if (cursor != null) {
        final int photoNameIndex = cursor.getColumnIndex(PhotoContract.PhotoViewColumns.NAME);
        title = cursor.getString(photoNameIndex);
    } else {
        title = null;
    }

    if (mIsEmpty || !hasAlbumCount || position <= 0) {
        subtitle = null;
    } else {
        subtitle = getResources().getString(R.string.photo_view_count, position, mAlbumCount);
    }

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setTitle(title);
    actionBar.setSubtitle(subtitle);
}

From source file:com.mediatek.galleryfeature.stereo.segment.background.StereoBackgroundActivity.java

private void setActionBarDisplayOptions(ActionBar actionBar, boolean displayHomeAsUp, boolean showTitle) {
    if (actionBar == null) {
        return;/*from   ww  w .j  av a  2s  . c o  m*/
    }
    int options = 0;
    if (displayHomeAsUp) {
        options |= ActionBar.DISPLAY_HOME_AS_UP;
    }
    if (showTitle) {
        options |= ActionBar.DISPLAY_SHOW_TITLE;
    }

    actionBar.setDisplayOptions(options, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setHomeButtonEnabled(displayHomeAsUp);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setTitle(R.string.m_save);
}

From source file:com.chen.mail.ui.AbstractActivityController.java

/**
 * Attach the action bar to the activity.
 *//*w ww.  j ava  2 s  .com*/
private void attachActionBar() {
    final ActionBar actionBar = mActivity.getActionBar();
    if (actionBar != null && mActionBarView != null) {
        actionBar.setCustomView(mActionBarView,
                new ActionBar.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
        // Show a custom view and home icon, keep the title and subttitle
        final int mask = ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE
                | ActionBar.DISPLAY_SHOW_HOME;
        actionBar.setDisplayOptions(mask, mask);
    }
    mViewMode.addListener(mActionBarView);
}

From source file:com.indeema.mail.ui.AbstractActivityController.java

/**
 * Attach the action bar to the activity.
 *///from  w ww .j av  a 2s . c  om
private void attachActionBar() {
    final ActionBar actionBar = mActivity.getActionBar();
    if (actionBar != null && mActionBarView != null) {
        actionBar.setCustomView(mActionBarView,
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
        // Show a custom view and home icon, keep the title and subttitle
        final int mask = ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE
                | ActionBar.DISPLAY_SHOW_HOME;
        actionBar.setDisplayOptions(mask, mask);
    }
    mViewMode.addListener(mActionBarView);
}

From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM;
    MenuItem item;//from   www.  j  a va 2s .com
    if (currentFragment != ScreenList.WEBKIT) {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE);
        actionBar.show();

        item = menu.add(Menu.NONE, MENU_FILL_FORM, Menu.NONE, getString(R.string.enter_data_button));
        item.setIcon(R.drawable.ic_action_collections_collection).setShowAsAction(showOption);

        // Using a file for this work now
        String get = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_GET_BLANK);
        if (get.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PULL_FORMS, Menu.NONE, getString(R.string.get_forms));
            item.setIcon(R.drawable.ic_action_av_download).setShowAsAction(showOption);

            item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, getString(R.string.get_forms));
            item.setIcon(R.drawable.ic_action_cloud).setShowAsAction(showOption);
        }

        String send = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_SEND_FINALIZED);
        if (send.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PUSH_FORMS, Menu.NONE, getString(R.string.send_data));
            item.setIcon(R.drawable.ic_action_av_upload).setShowAsAction(showOption);
        }

        String manage = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_MANAGE_FORMS);
        if (manage.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_MANAGE_FORMS, Menu.NONE, getString(R.string.manage_files));
            item.setIcon(R.drawable.trash).setShowAsAction(showOption);
        }

        String settings = PropertiesSingleton.getProperty(appName,
                AdminPreferencesActivity.KEY_ACCESS_SETTINGS);
        if (settings.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PREFERENCES, Menu.NONE, getString(R.string.general_preferences));
            item.setIcon(R.drawable.ic_menu_preferences).setShowAsAction(showOption);
        }
        item = menu.add(Menu.NONE, MENU_ADMIN_PREFERENCES, Menu.NONE, getString(R.string.admin_preferences));
        item.setIcon(R.drawable.ic_action_device_access_accounts).setShowAsAction(showOption);

        item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, getString(R.string.about));
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    } else {
        ActionBar actionBar = getActionBar();
        actionBar.hide();
    }

    return true;
}

From source file:org.path.episample.android.activities.MainMenuActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM;
    MenuItem item;/*from w  w w .ja  va  2  s.c  o  m*/
    if (currentFragment != ScreenList.WEBKIT) {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE);
        actionBar.show();

        item = menu.add(Menu.NONE, MENU_MAIN_MENU, Menu.NONE, getString(R.string.main_menu));
        item.setIcon(R.drawable.ic_action_home).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

        //item = menu.add(Menu.NONE, MENU_FILL_FORM, Menu.NONE, getString(R.string.enter_data_button));
        //item.setIcon(R.drawable.ic_action_collections_collection).setShowAsAction(showOption);

        // Using a file for this work now
        String get = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_GET_BLANK);
        if (get.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PULL_FORMS, Menu.NONE, getString(R.string.get_forms));
            item.setIcon(R.drawable.ic_action_av_download).setShowAsAction(showOption);

            //item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, getString(R.string.get_forms));
            //item.setIcon(R.drawable.ic_action_cloud).setShowAsAction(showOption);
        }

        String send = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_SEND_FINALIZED);
        if (send.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PUSH_FORMS, Menu.NONE, getString(R.string.send_data));
            item.setIcon(R.drawable.ic_action_av_upload).setShowAsAction(showOption);
        }

        String manage = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_MANAGE_FORMS);
        if (manage.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_MANAGE_FORMS, Menu.NONE, getString(R.string.manage_files));
            item.setIcon(R.drawable.trash).setShowAsAction(showOption);
        }

        String settings = PropertiesSingleton.getProperty(appName,
                AdminPreferencesActivity.KEY_ACCESS_SETTINGS);
        if (settings.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PREFERENCES, Menu.NONE, getString(R.string.general_preferences));
            item.setIcon(R.drawable.ic_menu_preferences).setShowAsAction(showOption);
        }
        item = menu.add(Menu.NONE, MENU_ADMIN_PREFERENCES, Menu.NONE, getString(R.string.admin_preferences));
        item.setIcon(R.drawable.ic_action_device_access_accounts).setShowAsAction(showOption);

        String backup = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_BACKUP_CENSUS);
        if (backup != null && backup.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_BACKUP_CENSUS, Menu.NONE, getString(R.string.backup_census));
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }

        String restore = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_RESTORE_CENSUS);
        if (restore != null && restore.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_RESTORE_CENSUS, Menu.NONE, getString(R.string.restore_census));
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }

        String invalidateCensus = PropertiesSingleton.getProperty(appName,
                AdminPreferencesActivity.KEY_INVALIDATE_CENSUS);
        if (invalidateCensus != null && invalidateCensus.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_MARK_CENSUS_AS_INVALID, Menu.NONE,
                    getString(R.string.invalidate_census));
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }

        String edit = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_EDIT_CENSUS);
        if (edit != null && edit.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_EDIT_CENSUS, Menu.NONE, getString(R.string.edit_census));
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }

        String removeCensus = PropertiesSingleton.getProperty(appName,
                AdminPreferencesActivity.KEY_REMOVE_CENSUS);
        if (removeCensus != null && removeCensus.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_REMOVE_CENSUS, Menu.NONE, getString(R.string.remove_census));
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }

        /*String send_receive_bt = PropertiesSingleton.getProperty(appName,
                AdminPreferencesActivity.KEY_SEND_RECEIVE_BLUETOOTH);
        if (send_receive_bt != null && send_receive_bt.equalsIgnoreCase("true")) {
           item = menu.add(Menu.NONE, MENU_SEND_REVEIVE_BLUETOOTH, Menu.NONE, getString(R.string.send_receive_bluetooth));
           item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }*/

        item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, getString(R.string.about));
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    } else {
        ActionBar actionBar = getActionBar();
        actionBar.hide();
    }

    return true;
}

From source file:org.mozilla.gecko.GeckoApp.java

public void refreshActionBar() {
    if (Build.VERSION.SDK_INT >= 11) {
        mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.browser_toolbar, null);
        mBrowserToolbar.init();//from  w  ww .  j  a va  2  s . c o  m
        mBrowserToolbar.refresh();
        GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg));
        GeckoActionBar.setDisplayOptions(this, ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM
                | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_USE_LOGO);
        GeckoActionBar.setCustomView(this, mBrowserToolbar);
    }
}