Example usage for android.app ActionBar setTitle

List of usage examples for android.app ActionBar setTitle

Introduction

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

Prototype

public abstract void setTitle(@StringRes int resId);

Source Link

Document

Set the action bar's title.

Usage

From source file:com.tweetlanes.android.core.view.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    AccountDescriptor account = getApp().getCurrentAccount();

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        // Notifications
        String accountKey = extras.getString("account_key");
        String notificationType = extras.getString("notification_type");
        long notificationPostId = extras.getLong("notification_post_id");
        String laneName = extras.getString("lane");
        final String urlToLoad = extras.getString("urlToLoad");

        if (accountKey != null) {
            getIntent().removeExtra("account_key");
            getIntent().removeExtra("notification_type");
            AccountDescriptor notificationAccount = getApp().getAccountByKey(accountKey);

            Notifier.saveLastNotificationActioned(this, accountKey, notificationType, notificationPostId);

            Constant.LaneType notificationLaneType = notificationType.equals(
                    SharedPreferencesConstants.NOTIFICATION_TYPE_MENTION) ? Constant.LaneType.USER_MENTIONS
                            : Constant.LaneType.DIRECT_MESSAGES;

            if (notificationAccount != null) {
                long notificationAccountId = notificationAccount.getId();
                long currentAccountId = account.getId();
                if (notificationAccountId == currentAccountId) {
                    int index = account.getCurrentLaneIndex(notificationLaneType);
                    if (index > -1) {
                        mDefaultLaneOverride = index;
                    }//from   w  ww  .j  a v a 2 s .c om
                } else {
                    showAccount(notificationAccount, notificationLaneType);
                }
            }
        } else if (laneName != null) {
            getIntent().removeExtra("lane");
            int index = account.getCurrentLaneIndex(Constant.LaneType.valueOf(laneName.trim().toUpperCase()));
            if (index > -1) {
                mDefaultLaneOverride = index;
            }
        } else if (urlToLoad != null) {
            getIntent().removeExtra("urlToLoad");
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
            alertDialogBuilder.setMessage(getString(R.string.unknown_intent));
            alertDialogBuilder.setPositiveButton(getString(R.string.yes),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            Intent viewIntent = new Intent("android.intent.action.VIEW",
                                    Uri.parse(urlToLoad.trim()));
                            startActivity(viewIntent);
                        }
                    });
            alertDialogBuilder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            alertDialogBuilder.create().show();
        }
    }

    super.onCreate(savedInstanceState);

    // Attempt at fixing a crash found in HomeActivity
    if (account == null) {
        Toast.makeText(getApplicationContext(), "No cached account found, restarting",
                Constant.DEFAULT_TOAST_DISPLAY_TIME).show();
        restartApp();
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setTitle(null);
    actionBar.setDisplayShowTitleEnabled(false);

    mSpinnerAdapter = new AccountAdapter(this, getApp().getAccounts());

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
    actionBar.setSelectedNavigationItem(0);

    onCreateNavigationListener();
    configureListNavigation();

    mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher);
    updateViewVisibility();

    onCreateHandleIntents();

    account.setDisplayedLaneDefinitionsDirty(false);

    Notifier.setNotificationAlarm(this);

    clearTempFolder();

    cacheFollowers();

    //Launch change log dialog
    final WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this);
    whatsNewDialog.show();
}

From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java

/** Called when the activity is first created. */
@Override/* w  w  w. j  a  v  a  2  s .  co  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mood_history);
    mDayDataHandler = new DayDataHandler(this);

    mCurrentSprint = getIntent().getExtras().getParcelable(Sprint.CURRENT_SPRINT);
    mRes = getResources();
    mSprintStartDateInMillis = mCurrentSprint.getStartTime();
    mSprintEndDateInMillis = mCurrentSprint.getEndTime();

    mDaysInSprint = mCurrentSprint.getDaysInSprint();
    ActionBar actionBar = getActionBar();

    Calendar mToday = Calendar.getInstance();
    UtilityMethods.setToDayStart(mToday);
    mToday.setFirstDayOfWeek(Calendar.MONDAY);

    mNumberOfTodayInSprint = mCurrentSprint.getCurrentDayOfTheSprint();

    // Check if the sprint is already over.
    if (mNumberOfTodayInSprint > mDaysInSprint) {
        mNumberOfTodayInSprint = mDaysInSprint;
    }
    actionBar.setSubtitle(mCurrentSprint.getSprintTitle());
    actionBar.setTitle(mNumberOfTodayInSprint + " " + getString(R.string.days));
    actionBar.setBackgroundDrawable(mRes.getDrawable(R.drawable.action_bar_orange));

    mStartDate = Calendar.getInstance();
    mStartDate.setFirstDayOfWeek(Calendar.MONDAY);
    mStartDate.setTimeInMillis(mSprintStartDateInMillis);

    // Calculate the number of weeks in the sprint
    mNumberOfWeeksInSprint = mToday.get(Calendar.WEEK_OF_YEAR) - mStartDate.get(Calendar.WEEK_OF_YEAR) + 1;
    if (mNumberOfWeeksInSprint < 0) {
        mNumberOfWeeksInSprint = 52 + 1 - mStartDate.get(Calendar.WEEK_OF_YEAR)
                + mToday.get(Calendar.WEEK_OF_YEAR);
    } else {

    }

    // Sets the default selections as today or this week.
    mSelectedDay = mNumberOfTodayInSprint - 1;
    mSelectedWeek = mNumberOfWeeksInSprint - 1;
    mViewPager = (ViewPager) findViewById(R.id.activity_mood_history_viewpager);

    titleIndicator = (TitlePageIndicator) findViewById(R.id.indicator);

    // Page change listener to keep the selected week and day in a member.
    titleIndicator.setOnPageChangeListener(new OnPageChangeListener() {
        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

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

        @Override
        public void onPageSelected(int arg0) {
            if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                mSelectedDay = arg0;
            } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                mSelectedWeek = arg0;
                MoodHistoryWeekFragment fragment = mPagerAdapterWeek.getWeekFragment(arg0);
                if (fragment != null) {
                    fragment.updateSelectedAttribute(mSelectedAttribute, false);
                }
            }
        }
    });

    setPageTitles();

    // Load correct layout and functionality based on orientation
    if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        loadPortraitView();
    } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        loadLandscapeView();
    }

}

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

private void setActionBarDisplayOptions(ActionBar actionBar, boolean displayHomeAsUp, boolean showTitle) {
    if (actionBar == null) {
        return;/* ww  w  .  j  a va 2 s .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:org.catnut.ui.HelloActivity.java

private void init() {
    setContentView(R.layout.about);//from w  w w.  ja va 2 s.c o m

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOnPageChangeListener(new PagerListener());

    mImages = new ArrayList<Image>();

    mPagerAdapter = new Gallery();
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setPageTransformer(true, new PageTransformer.DepthPageTransformer());
    if (mTargetFromGrid != null) {
        mImages.add(mTargetFromGrid);
        mPagerAdapter.notifyDataSetChanged();
    }

    mAbout = findViewById(R.id.about);
    mFantasyDesc = (TextView) findViewById(R.id.description);
    mFantasyDesc.setMovementMethod(LinkMovementMethod.getInstance());
    ActionBar bar = getActionBar();
    TextView about = (TextView) findViewById(R.id.about_body);
    TextView version = (TextView) findViewById(R.id.app_version);
    TextView appName = (TextView) findViewById(R.id.app_name);
    TextView weiboApp = (TextView) findViewById(R.id.weibo_app);
    weiboApp.setText(R.string.weibo_app);
    appName.setText(R.string.app_name);
    TextView appDesc = (TextView) findViewById(R.id.app_desc);
    appDesc.setText(R.string.app_desc);
    if (CatnutApp.getBoolean(R.string.pref_fantasy_say_salutation, R.bool.default_fantasy_say_salutation)) {
        version.setText(getString(R.string.about_version_template, getString(R.string.version_name)));
        int n = (int) (Math.random() * 101);
        if (0 < n && n < 35) {
            bar.setTitle(R.string.fantasy);
            about.setText(Html.fromHtml(getString(R.string.about_body)));
            about.setMovementMethod(LinkMovementMethod.getInstance());
        } else {
            bar.setTitle(R.string.fantasy);
            about.setText(Html.fromHtml(getString(R.string.salutation)));
            about.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
        }
    } else {
        mAbout.setVisibility(View.GONE);
    }

    loadImage();
    mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    if (mApp.getPreferences().getBoolean(getString(R.string.enable_analytics), true)) {
        mTracker = EasyTracker.getInstance(this);
    }
}

From source file:com.cypress.cysmart.CommonFragments.ProfileScanningFragment.java

/**
 * Setting up the ActionBar//from  w w  w  .  ja v a2s. c o  m
 */
void setUpActionBar() {
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    }
    if (actionBar != null) {
        actionBar.setTitle(R.string.profile_scan_fragment);
    }
}

From source file:com.android.contacts.activities.ContactDetailActivity.java

/** @} */

@Override//from  w w w.  j  av  a2  s. com
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    LogUtils.i(TAG, "[onCreate][launch]start");
    ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet
    registerPHBReceiver();
    mIsActivitFinished = false;
    /** M: Bug Fix for ALPS00393950 @{ */
    boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this);
    if (!isUsingTwoPanes) {
        SetIndicatorUtils.getInstance().registerReceiver(this);
    }
    /** @} */
    if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        // This activity must not be shown. We have to select the contact in the
        // PeopleActivity instead ==> Create a forward intent and finish
        final Intent originalIntent = getIntent();
        Intent intent = new Intent();
        intent.setAction(originalIntent.getAction());
        intent.setDataAndType(originalIntent.getData(), originalIntent.getType());

        // If we are launched from the outside, we should create a new task, because the user
        // can freely navigate the app (this is different from phones, where only the UP button
        // kicks the user into the full app)
        if (shouldUpRecreateTask(intent)) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        } else {
            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }
        intent.setClass(this, PeopleActivity.class);
        startActivity(intent);
        LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity..");
        finish();
        return;
    }

    setContentView(R.layout.contact_detail_activity);

    mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(),
            null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener);

    // We want the UP affordance but no app icon.
    // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick.
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        ///@Modify for add Customer view{
        actionBar.setDisplayOptions(
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM,
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
                        | ActionBar.DISPLAY_SHOW_CUSTOM);
        ///@}
        actionBar.setTitle("");
    }

    Log.i(TAG, getIntent().getData().toString());
    /** M: New Feature xxx @{ */
    //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE
    if (getIntent() != null && getIntent().getData() != null) {
        mSimOrPhoneUri = getIntent().getData();
        Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri);
    } else {
        Log.e(TAG, "Get intent data error getIntent() = " + getIntent());
    }
    /// M: @ CT contacts detail history set listener{
    ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(),
            ContactPluginDefault.COMMD_FOR_OP09);
    /// @}
    LogUtils.i(TAG, "[onCreate][launch]end");
}

From source file:org.bohrmeista.chan.ui.activity.BoardActivity.java

private void updateActionBarStateCallback() {
    final ActionBar actionBar = getActionBar();

    if (threadPane.isSlideable()) {
        if (threadPane.isOpen()) {
            actionBar.setDisplayShowCustomEnabled(true);
            if (ChanApplication.getBoardManager().getBoardExists(boardLoadable.board)) {
                spinnerAdapter.setCustomBoard(null);
            } else {
                spinnerAdapter.setCustomBoard(boardLoadable.board);
            }/*from  ww  w  . j  av  a  2  s.c  o m*/

            spinnerAdapter.setBoard(boardLoadable.board);

            actionBar.setTitle("");
            pinDrawerListener.setDrawerIndicatorEnabled(true);

            if (boardLoadable.isBoardMode()) {
                setShareUrl(ChanUrls.getBoardUrlDesktop(boardLoadable.board));
            } else if (boardLoadable.isCatalogMode()) {
                setShareUrl(ChanUrls.getCatalogUrlDesktop(boardLoadable.board));
            }
        } else {
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.setTitle(threadLoadable.title);
            pinDrawerListener.setDrawerIndicatorEnabled(false);

            if (threadLoadable.isThreadMode())
                setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    } else {
        actionBar.setDisplayShowCustomEnabled(true);
        pinDrawerListener.setDrawerIndicatorEnabled(true);
        actionBar.setTitle(threadLoadable.title);

        if (threadLoadable.isThreadMode()) {
            setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    }

    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);

    invalidateOptionsMenu();
}

From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java

/**
 * Load the list of currently live sessions or upcoming live sessions. This
 * populates the Action Bar (either the title or as list navigation.
 *//*  ww w  .  j ava 2 s.  c  o m*/
private void loadSessionsList(Cursor data) {
    mLivestreamAdapter.swapCursor(data);
    if (data != null && data.getCount() > 0) {
        mSessionsFound = true;
        final ActionBar actionBar = getActionBar();
        if (data.getCount() == 1) {
            // Just one session on, display title in Action Bar
            if (data.moveToFirst()) {
                actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
                actionBar.setDisplayShowTitleEnabled(true);
                actionBar.setTitle(data.getString(SessionsQuery.TITLE));
            }
        } else if (data.getCount() > 1) {
            // 2+ sessions found, set Action Bar to list navigation (spinner)
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setListNavigationCallbacks(mLivestreamAdapter, this);
            actionBar.setDisplayShowTitleEnabled(false);
            getActionBar().setSelectedNavigationItem(locateSelectedItem(data));
        }
    } else if (mSessionsFound) {
        // Sessions were previously found but no sessions are currently live,
        // adjust query to see if there are any future sessions at all
        mSessionsFound = false;
        final Bundle bundle = new Bundle();
        bundle.putBoolean(LOADER_SESSIONS_ARG, true);
        getLoaderManager().restartLoader(SessionsQuery._TOKEN, bundle, this);
    } else {
        // No sessions live right now and no sessions coming up, get out
        finish();
    }
}

From source file:com.android.email.activity.setup.MailboxSettings.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // This needs to happen before super.onCreate() since that calls onBuildHeaders()
    mInboxId = getIntent().getIntExtra(EXTRA_INBOX_ID, -1);
    mFoldersUri = getIntent().getParcelableExtra(EXTRA_FOLDERS_URI);
    mType = getIntent().getStringExtra(EXTRA_TYPE);

    if (mFoldersUri != null) {
        getLoaderManager().initLoader(FOLDERS_LOADER_ID, null, new MailboxSettingsFolderLoaderCallbacks());
    }/* ww  w.  j  ava2  s  .co m*/

    super.onCreate(savedInstanceState);

    // Always show "app up" as we expect our parent to be an Email activity.
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
        // Hide the app icon.
        actionBar.setIcon(android.R.color.transparent);
        actionBar.setDisplayUseLogoEnabled(false);
        if (mType != null && mType.equals(PREFERENCE_SYNC_SETTINGS)) {
            actionBar.setTitle(getString(R.string.mailbox_settings_activity_title));
        } else if (mType != null && mType.equals(PREFERENCE_PER_FOLDER_NOTIFICATIONS)) {
            actionBar.setTitle(getString(R.string.mailbox_notify_settings_activity_title));
        }
    }
}

From source file:uk.org.downiesoft.slideshow.GridViewFragment.java

/**
 * Set the title/subtitle in the ActionBar to reflect the current path/sub-path
 * @param aFile The current file location.
 *//*from www.j  a  va 2 s.  c om*/
private void setStatus(final ZFile aFile) {
    final ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        String subPath = aFile.getSubPath();
        String images = getString(R.string.text_images_placeholder);
        if (subPath.endsWith(images)) {
            subPath = subPath.substring(subPath.lastIndexOf(images));
            if (subPath.endsWith(File.separator)) {
                subPath = subPath.substring(0, subPath.length() - 1);
            }
        }
        if (aFile.isZipFile()) {
            File zip = new File(aFile.getRootPath());
            actionBar.setTitle(zip.getName());
            if (subPath.length() == 0) {
                actionBar.setSubtitle(null);
            } else {
                if (subPath.length() > 30) {
                    subPath = "\u2026" + subPath.substring(subPath.length() - 30);
                }
                actionBar.setSubtitle(subPath);
            }
        } else {
            actionBar.setTitle(aFile.getName());
            actionBar.setSubtitle(null);
        }
    }
}