Example usage for android.app ActionBar setSubtitle

List of usage examples for android.app ActionBar setSubtitle

Introduction

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

Prototype

public abstract void setSubtitle(@StringRes int resId);

Source Link

Document

Set the action bar's subtitle.

Usage

From source file:net.networksaremadeofstring.rhybudd.FirstRunSettings.java

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

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setTitle(getString(R.string.FirstRunTitle));
    actionBar.setSubtitle(getString(R.string.FirstRunSubtitle));

    // Create the adapter that will return a fragment for each of the three
    // 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/*from  w ww  .j  av  a2  s  .c om*/
        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));
    }
}

From source file:com.lithiumli.fiction.LibraryActivity.java

@Override
public void onPageSelected(int position) {
    ActionBar actionBar = getActionBar();
    actionBar.setSubtitle(mTabsAdapter.getPageTitle(position));

    // TODO: replace with something better
    switch (position) {
    case 0:/*www.j  av  a 2  s.c om*/
        mIndicator.setSelectedColor(0xFF9933CC);
        break;
    case 1:
        mIndicator.setSelectedColor(0xFFFF8800);
        break;
    case 2:
        mIndicator.setSelectedColor(0xFFCC0000);
        break;
    default:
        mIndicator.setSelectedColor(0xFF9933CC);
    }
}

From source file:com.example.android.adp.MainActivity.java

private void setStatus(CharSequence subTitle) {
    ActionBar actionBar = getActionBar();
    if (null == actionBar) {
        return;/*from   ww w .  j  a v a2s . c o  m*/
    }
    actionBar.setSubtitle(subTitle);
}

From source file:com.example.android.adp.MainActivity.java

private void setStatus(int resId) {
    final ActionBar actionBar = getActionBar();
    if (null == actionBar) {
        return;//from  w  ww.j a  v  a 2s. c  om
    }
    actionBar.setSubtitle(resId);
}

From source file:net.cherryzhang.sekuhara.BluetoothButtonAndChat.BluetoothChat.BluetoothChat.java

private final void setStatus(CharSequence subTitle) {
    final ActionBar actionBar = getActivity().getActionBar();
    actionBar.setSubtitle(subTitle);
}

From source file:com.dabay6.android.apps.carlog.ui.SettingsActivity.java

/**
 * {@inheritDoc}/*from   ww  w  .  j a v a2s.c om*/
 */
@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (AndroidUtils.isAtLeastHoneycomb()) {
        @SuppressLint("AppCompatMethod")
        final android.app.ActionBar actionBar = getActionBar();

        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setSubtitle(getString(string.settings));

            if (AndroidUtils.isAtLeastICS()) {
                actionBar.setHomeButtonEnabled(true);
            }
        }
    }

    if (AndroidUtils.isVersionBefore(VERSION_CODES.HONEYCOMB)) {
        addPreferencesFromResource(xml.settings);
    }
}

From source file:com.plnyyanks.frcnotebook.activities.ViewEvent.java

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

    activity = this;

    if (event == null) {
        Intent intent = new Intent(this, StartActivity.class);
        startActivity(intent);/*  w w w.  j a va  2 s .  c o m*/
        return;
    }

    ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setTitle(event.getEventName());
    bar.setSubtitle("#" + key);
    bar.setDisplayHomeAsUpEnabled(true);

    //tab for team list
    ActionBar.Tab teamListTab = bar.newTab();
    teamListTab.setText("Teams Attending");
    teamListTab.setTabListener(this);
    bar.addTab(teamListTab);

    //tab for match schedule
    ActionBar.Tab scheduleTab = bar.newTab();
    scheduleTab.setText("Match Schedule");
    scheduleTab.setTabListener(this);
    bar.addTab(scheduleTab);

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

From source file:net.cherryzhang.sekuhara.BluetoothButtonAndChat.BluetoothChat.BluetoothChat.java

private final void setStatus(int resId) {
    if (getActivity() != null) {
        final ActionBar actionBar = getActivity().getActionBar();
        actionBar.setSubtitle(resId);
    }// w w  w  .  j a va2  s . c o m

}

From source file:net.kw.shrdlu.grtgtfs.Activities.MenuMapActivity.java

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

    // Make sure we get the correct API key to match the build key.
    if (GRTApplication.isDebugBuild) {
        setContentView(R.layout.mapview_debug);
    } else {/*from  w w  w.  j  a  v a 2s.c o  m*/
        setContentView(R.layout.mapview);
    }

    mMapview = (MapView) findViewById(R.id.mapview);
    mMapview.setBuiltInZoomControls(true);

    mapOverlays = mMapview.getOverlays();

    View mDetailArea = findViewById(R.id.mapview);

    getActionBar().setTitle(R.string.loading_stops);
    getActionBar().setSubtitle(null);

    mMylocation = new MyLocationOverlay(this, mMapview);
    mapOverlays.add(mMylocation);

    mStopsOverlay = new StopsOverlay(mContext);

    // Load up the navigation drawer
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerListView = (ListView) findViewById(R.id.left_drawer);

    mNavAdapter = new NavDrawerListAdapter(mContext, R.layout.drawer_list_item, mDrawerItems);
    mDrawerListView.setAdapter(mNavAdapter);

    mDrawerToggle = new ActionBarDrawerToggle(mContext, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {

        CharSequence savedtitle, savedsubtitle;

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            final ActionBar ab = getActionBar();
            if (ab != null) {
                ab.setSubtitle(savedsubtitle);
                ab.setTitle(savedtitle);
            }
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            final ActionBar ab = getActionBar();
            if (ab != null) {
                savedtitle = ab.getTitle();
                savedsubtitle = ab.getSubtitle();
                ab.setTitle(R.string.app_name);
                ab.setSubtitle(null);
            }
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            mDrawerLayout.closeDrawers();
            NavOptions.onNavOptionSelected(mContext, mDrawerItems.get(position).getId());
        }
    });

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    mDrawerToggle.setDrawerIndicatorEnabled(false);
}

From source file:org.getlantern.firetweet.fragment.support.SearchFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);/*from w w w .  j  a  v  a2  s.  co  m*/
    final Bundle args = getArguments();
    final FragmentActivity activity = getActivity();
    mAdapter = new SupportTabsAdapter(activity, getChildFragmentManager(), null, 1);
    mAdapter.addTab(StatusesSearchFragment.class, args, getString(R.string.statuses),
            R.drawable.ic_action_twitter, 0, null);
    mAdapter.addTab(SearchUsersFragment.class, args, getString(R.string.users), R.drawable.ic_action_user, 1,
            null);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOffscreenPageLimit(2);
    mPagerIndicator.setViewPager(mViewPager);
    mPagerIndicator.setTabDisplayOption(TabPagerIndicator.LABEL);
    mPagerIndicator.setOnPageChangeListener(this);
    ThemeUtils.initPagerIndicatorAsActionBarTab(activity, mPagerIndicator);
    ThemeUtils.setCompatToolbarOverlay(activity, new EmptyDrawable());
    if (savedInstanceState == null && args != null && args.containsKey(EXTRA_QUERY)) {
        final String query = args.getString(EXTRA_QUERY);
        final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
                RecentSearchProvider.AUTHORITY, RecentSearchProvider.MODE);
        suggestions.saveRecentQuery(query, null);
        final ContentResolver cr = getContentResolver();
        final ContentValues values = new ContentValues();
        values.put(SearchHistory.QUERY, query);
        cr.insert(SearchHistory.CONTENT_URI, values);
        if (activity instanceof LinkHandlerActivity) {
            final ActionBar ab = activity.getActionBar();
            if (ab != null) {
                ab.setSubtitle(query);
            }
        }
    }
    updateTabOffset();
}