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.shafiq.mytwittle.view.BaseLaneActivity.java

boolean composeReleaseFocus(boolean forceCleanup) {

    boolean result = false;

    if (mCurrentComposeFragment != null && mCurrentComposeFragment.hasFocus()) {
        mCurrentComposeFragment.releaseFocus(true);
        forceCleanup = true;/*from ww w  .ja  v a  2s .  c o  m*/
        result = true;
    }

    if (forceCleanup) {
        ActionBar actionBar = getActionBar();
        actionBar.setTitle(null);
        actionBar.setDisplayShowTitleEnabled(false);
        invalidateOptionsMenu();
    }
    return result;
}

From source file:com.amagi82.kerbalspaceapp.CelestialBodyActivity.java

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

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(R.string.app_name);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter, passing in the appropriate page
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setCurrentItem(getIntent().getIntExtra(EXTRA_PLANET_ID, 0));
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        // onPageSelected finds the current page. invalidateOptionsMenu() resets the action bar for each page.
        @Override/* w w  w  .  j  av a  2 s  . c om*/
        public void onPageSelected(int position) {
            mCurrentPage = position;
            invalidateOptionsMenu();
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }
    });
    // Provides action bar settings on initial page creation
    mCurrentPage = getIntent().getIntExtra(EXTRA_PLANET_ID, 0);
}

From source file:fm.krui.kruifm.StreamContainer.java

/**
 * Styles the ActionBar appropriately based on the fragment to be loaded
 * @param fragmentId Integer identifier of fragment
 *//*  ww w .j a v  a  2s  .c  o m*/
private void applyActionBarParameters(int fragmentId) {
    // Default params
    ActionBar actionBar = getActionBar();
    String title = "";
    String subTitle = "";
    int navigationMode = ActionBar.NAVIGATION_MODE_STANDARD;

    // Set params based on opening tab
    switch (fragmentId) {
    case STREAM_TAB:
        //navigationMode = ActionBar.NAVIGATION_MODE_LIST;
        break;
    case PLAYLIST_TAB:
        title = getString(R.string.extended_playlist_title);
        subTitle = getString(R.string.extended_playlist_subtitle);
        break;
    case DJ_TAB:
        title = getString(R.string.dj_info_tab);
        break;
    case FAVORITE_TRACKS_TAB:
        title = getString(R.string.favorite_tracks_title);
        subTitle = getString(R.string.favorite_tracks_subtitle);
        break;
    case MUSIC_ARTICLES_TAB:
        title = getString(R.string.music_content_sidebar);
        break;
    case NEWS_ARTICLES_TAB:
        title = getString(R.string.news_content_sidebar);
        break;
    case SPORTS_ARTICLES_TAB:
        title = getString(R.string.sports_content_sidebar);
        break;
    }

    // Apply parameters
    actionBar.setNavigationMode(navigationMode);
    actionBar.setTitle(title);
    actionBar.setSubtitle(subTitle);
}

From source file:ca.mimic.apphangar.Settings.java

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

    setContentView(R.layout.activity_settings);

    prefs = new PrefsGet(getSharedPreferences(getPackageName(), Context.MODE_MULTI_PROCESS));

    mContext = this;

    if (showChangelog(prefs)) {
        launchChangelog();//from  w w w  . j a  v  a 2 s . co  m
    }

    display = getWindowManager().getDefaultDisplay();
    updateDisplayWidth();

    myService = new ServiceCall(mContext);
    myService.setConnection(mConnection);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    actionBar.setTitle(R.string.title_activity_settings);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setCustomView(R.layout.action_spinner);
    setUpSpinner((Spinner) actionBar.getCustomView().findViewById(R.id.config_spinner));
    actionBar.setDisplayShowCustomEnabled(true);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(4);

    mGetFragments = new GetFragments();
    mGetFragments.setFm(getFragmentManager());
    mGetFragments.setVp(mViewPager);

    ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    };

    mViewPager.setOnPageChangeListener(pageChangeListener);

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    pageChangeListener.onPageSelected(GENERAL_TAB);

}

From source file:com.geotrackin.gpslogger.GpsMainActivity.java

public void SetUpActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(),
            R.array.gps_main_views, android.R.layout.simple_spinner_dropdown_item);

    actionBar.setListNavigationCallbacks(spinnerAdapter, this);

    //Reload the user's previously selected view f73
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    actionBar.setSelectedNavigationItem(prefs.getInt("dropdownview", 0));

    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("");
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
            | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.actionbar);

    ImageButton helpButton = (ImageButton) actionBar.getCustomView().findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override/*  w  ww  .java 2 s  .co  m*/
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

public void updateActionBar() {
    final ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowHomeEnabled(true);

    final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE);
    actionBar.setDisplayHomeAsUpEnabled(showIndicator);
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(showIndicator);
    }// w  w  w .j av a 2s.com

    if (isRootsDrawerOpen()) {
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setIcon(new ColorDrawable());

        if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
            actionBar.setTitle(R.string.title_open);
        } else if (mState.action == ACTION_CREATE) {
            actionBar.setTitle(R.string.title_save);
        }
    } else {
        final RootInfo root = getCurrentRoot();
        actionBar.setIcon(root != null ? root.loadIcon(this) : null);

        if (mState.stack.size() <= 1) {
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            actionBar.setTitle(root.title);
        } else {
            mIgnoreNextNavigation = true;
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setTitle(null);
            actionBar.setListNavigationCallbacks(mStackAdapter, mStackListener);
            actionBar.setSelectedNavigationItem(mStackAdapter.getCount() - 1);
        }
    }
}

From source file:com.yattatech.dbtc.activity.MainScreen.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_main_screen);
    final int color = getResources().getColor(R.color.grey2);
    final ActionBar actionBar = getActionBar();
    mFilter = new IntentFilter();
    mLocaleChangedFilter = new IntentFilter();
    mTaskList = (DragSortListView) findViewById(R.id.taskList);
    mTaskListAdapter = new TaskListAdapter(this);
    final String appKey = getString(R.string.dropbox_key);
    final String appSecret = getString(R.string.dropbox_secret);
    final AppKeyPair pair = new AppKeyPair(appKey, appSecret);
    final AndroidAuthSession session = new AndroidAuthSession(pair);
    mDropboxAPI = new DropboxAPI<AndroidAuthSession>(session);
    mToken = FACADE.getDropBoxToken();// w w w. j  a va2  s  . c  o m
    mTaskList.setAdapter(mTaskListAdapter);
    mTaskList.setOnItemClickListener(mTaskListListener);
    mTaskList.setDropListener(mDropListener);
    mTaskList.setDragScrollProfile(mScrollProfile);
    mTaskList.setFloatViewManager(new MainViewManager(mTaskList));
    mFilter.addAction(ADD_NEW_TASK_ACTION);
    mFilter.addAction(EDIT_TASK_ACTION);
    mFilter.addAction(REMOVE_TASK_ACTION);
    mFilter.addAction(BACKUP_RESTORE_ACTION);
    mLocaleChangedFilter.addAction(Intent.ACTION_LOCALE_CHANGED);
    actionBar.setIcon(R.drawable.ic_task);
    actionBar.setTitle(R.string.app_name);
    actionBar.setBackgroundDrawable(new ColorDrawable(color));
    Broadcaster.registerLocalReceiver(mReceiver, mFilter);
    registerReceiver(mLocaleChangedReceiver, mLocaleChangedFilter);
    registerForContextMenu(mTaskList);
    final List<Task> tasks = FACADE.getTasks();
    mTaskListAdapter.setElements(FACADE.restoreDataOrder(tasks));
}

From source file:dev.dworks.apps.anexplorer.DocumentsActivity.java

public void updateActionBar() {
    final ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowHomeEnabled(true);

    final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE);
    actionBar.setDisplayHomeAsUpEnabled(showIndicator);
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(showIndicator);
    }/*from  w w w. j  ava 2s  . c o  m*/

    if (isRootsDrawerOpen()) {
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setIcon(new ColorDrawable());

        if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT
                || mState.action == ACTION_BROWSE) {
            actionBar.setTitle(R.string.app_name);
            actionBar.setIcon(R.drawable.ic_launcher);
        } else if (mState.action == ACTION_CREATE) {
            actionBar.setTitle(R.string.title_save);
        }
    } else {
        final RootInfo root = getCurrentRoot();
        //actionBar.setIcon(root != null ? root.loadIcon(this) : null);

        if (mState.stack.size() <= 1) {
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            actionBar.setTitle(root.title);
        } else {
            mIgnoreNextNavigation = true;
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setTitle(null);
            actionBar.setListNavigationCallbacks(mStackAdapter, mStackListener);
            actionBar.setSelectedNavigationItem(mStackAdapter.getCount() - 1);
        }
    }
}

From source file:com.cyanogenmod.eleven.ui.activities.SearchActivity.java

/**
 * {@inheritDoc}/*w w  w . j  a  v a2 s.  c  om*/
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mPopupMenuHelper = new PopupMenuHelper(this, getSupportFragmentManager()) {
        private SearchResult mSelectedItem;

        @Override
        public PopupMenuType onPreparePopupMenu(int position) {
            mSelectedItem = mAdapter.getTItem(position);

            return PopupMenuType.SearchResult;
        }

        @Override
        protected long[] getIdList() {
            switch (mSelectedItem.mType) {
            case Artist:
                return MusicUtils.getSongListForArtist(SearchActivity.this, mSelectedItem.mId);
            case Album:
                return MusicUtils.getSongListForAlbum(SearchActivity.this, mSelectedItem.mId);
            case Song:
                return new long[] { mSelectedItem.mId };
            case Playlist:
                return MusicUtils.getSongListForPlaylist(SearchActivity.this, mSelectedItem.mId);
            default:
                return null;
            }
        }

        @Override
        protected long getSourceId() {
            return mSelectedItem.mId;
        }

        @Override
        protected Config.IdType getSourceType() {
            return mSelectedItem.mType.getSourceType();
        }

        @Override
        protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
            super.updateMenuIds(type, set);

            if (mSelectedItem.mType == ResultType.Album) {
                set.add(FragmentMenuItems.MORE_BY_ARTIST);
            }
        }

        @Override
        protected String getArtistName() {
            return mSelectedItem.mArtist;
        }
    };

    // Fade it in
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

    // Control the media volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Bind Apollo's service
    mToken = MusicUtils.bindToService(this, this);

    // Set the layout
    setContentView(R.layout.activity_search);

    // get the input method manager
    mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Initialize the adapter
    SummarySearchAdapter adapter = new SummarySearchAdapter(this);
    mAdapter = new SectionAdapter<SearchResult, SummarySearchAdapter>(this, adapter);
    // Set the prefix
    mAdapter.getUnderlyingAdapter().setPrefix(mFilterString);
    mAdapter.setupHeaderParameters(R.layout.list_search_header, false);
    mAdapter.setupFooterParameters(R.layout.list_search_footer, true);
    mAdapter.setPopupMenuClickedListener(new IPopupMenuCallback.IListener() {
        @Override
        public void onPopupMenuClicked(View v, int position) {
            mPopupMenuHelper.showPopupMenu(v, position);
        }
    });

    mLoadingEmptyContainer = (LoadingEmptyContainer) findViewById(R.id.loading_empty_container);
    // setup the no results container
    NoResultsContainer noResults = mLoadingEmptyContainer.getNoResultsContainer();
    noResults.setMainText(R.string.empty_search);
    noResults.setSecondaryText(R.string.empty_search_check);

    initListView();

    // setup handler and runnable
    mHandler = new Handler();
    mLoadingRunnable = new Runnable() {
        @Override
        public void run() {
            setState(VisibleState.Loading);
        }
    };

    // Theme the action bar
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Get the query String
    mFilterString = getIntent().getStringExtra(SearchManager.QUERY);

    // if we have a non-empty search string, this is a 2nd lvl search
    if (!TextUtils.isEmpty(mFilterString)) {
        mTopLevelSearch = false;

        // get the search type to filter by
        int type = getIntent().getIntExtra(SearchManager.SEARCH_MODE, -1);
        if (type >= 0 && type < ResultType.values().length) {
            mSearchType = ResultType.values()[type];
        }

        int resourceId = 0;
        switch (mSearchType) {
        case Artist:
            resourceId = R.string.search_title_artists;
            break;
        case Album:
            resourceId = R.string.search_title_albums;
            break;
        case Playlist:
            resourceId = R.string.search_title_playlists;
            break;
        case Song:
            resourceId = R.string.search_title_songs;
            break;
        }
        actionBar.setTitle(getString(resourceId, mFilterString).toUpperCase());
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Set the prefix
        mAdapter.getUnderlyingAdapter().setPrefix(mFilterString);

        // Start the loader for the query
        getSupportLoaderManager().initLoader(SEARCH_LOADER, null, this);
    } else {
        mTopLevelSearch = true;
        mSearchHistoryCallback = new SearchHistoryCallback();

        // Start the loader for the search history
        getSupportLoaderManager().initLoader(HISTORY_LOADER, null, mSearchHistoryCallback);
    }

    // set the background on the root view
    getWindow().getDecorView().getRootView()
            .setBackgroundColor(getResources().getColor(R.color.background_color));
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

private void updateTitle(ContactList list) {
    String title = null;/*  www  . ja v  a  2s. c om*/
    String subTitle = null;
    int cnt = list.size();
    switch (cnt) {
    case 0: {
        String recipient = null;
        if (mRecipientsEditor != null) {
            recipient = mRecipientsEditor.getText().toString();
        }
        title = TextUtils.isEmpty(recipient) ? getString(R.string.new_message) : recipient;
        break;
    }
    case 1: {
        title = list.get(0).getName(); // get name returns the number if there's no
                                       // name available.
        String number = list.get(0).getNumber();
        if (!title.equals(number)) {
            subTitle = PhoneNumberUtils.formatNumber(number, number,
                    MmsApp.getApplication().getCurrentCountryIso());
        }
        break;
    }
    default: {
        // Handle multiple recipients
        title = list.formatNames(", ");
        subTitle = getResources().getQuantityString(R.plurals.recipient_count, cnt, cnt);
        break;
    }
    }
    mDebugRecipients = list.serialize();

    ActionBar actionBar = getActionBar();
    actionBar.setTitle(title);
    actionBar.setSubtitle(subTitle);
}