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:net.vexelon.bgrates.ui.activities.MainActivity.java

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

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setTitle(R.string.app_name_pure);
    // actionBar.setDisplayUseLogoEnabled(true);
    // actionBar.setLogo(R.drawable.icon);

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

    // 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  ww w  .  j a  va2 s .com
        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));
    }

    // load default values
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    // Start Service
    startService();
}

From source file:com.aniruddhc.acemusic.player.PlaylistEditorActivity.PlaylistEditorActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.add_to_music_library, menu);

    ActionBar actionBar = getActionBar();
    SpannableString s = new SpannableString(getResources().getString(R.string.create_playlist));
    s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    actionBar.setTitle(s);

    return super.onCreateOptionsMenu(menu);
}

From source file:com.dictionary.activity.ArticleCollectionActivity.java

private void updateTitle(int position) {
    Log.d("updateTitle", "" + position + " count: " + articleCollectionPagerAdapter.getCount());
    Slob.Blob blob = articleCollectionPagerAdapter.get(position);
    CharSequence pageTitle = articleCollectionPagerAdapter.getPageTitle(position);
    Log.d("updateTitle", "" + blob);
    ActionBar actionBar = getActionBar();
    if (blob != null) {
        String dictLabel = blob.owner.getTags().get("label");
        actionBar.setTitle(dictLabel);
        Application app = (Application) getApplication();
        app.history.add(app.getUrl(blob));
    } else {/*from  w ww  .j a  v  a 2s  .co m*/
        actionBar.setTitle("???");
    }
    actionBar.setSubtitle(pageTitle);
}

From source file:run.ace.TabBar.java

public void setTitle(String title, android.app.Activity activity) {
    //if (!(activity instanceof ActionBarActivity)) {
    android.app.ActionBar actionBar = activity.getActionBar();
    if (actionBar == null) {
        throw new RuntimeException(
                "Cannot set title on the main page in Android unless you set <preference name=\"ShowTitle\" value=\"true\"/> in config.xml.");
    }/*from w w  w.  ja  v  a2  s .com*/
    actionBar.setTitle(title);
    //}
    //else {
    //    ActionBar actionBar = ((ActionBarActivity)activity).getSupportActionBar();
    //    if (actionBar != null) {
    //        actionBar.setTitle(title);
    //    }
    //}
}

From source file:com.rastating.droidbeard.MainActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);

    if (mTitle != null) {
        actionBar.setTitle(mTitle);
    }//from w  ww.  j  a v a  2 s  .  c o m
}

From source file:com.otaupdater.TabDisplay.java

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

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);// w w w.j  a  va2s.co m

    if (!Utils.haveProKey(context)) {
        cfg.setKeyExpiry(0);
    } else if (!cfg.hasValidProKey()) {
        if (cfg.isProKeyTemporary()) {
            if (cfg.getKeyExpires() < System.currentTimeMillis()) {
                Utils.verifyProKey(context);
            }
        } else {
            Utils.verifyProKey(context);
        }
    }

    if (!Utils.isRomOtaEnabled() && !Utils.isKernelOtaEnabled()) {
        if (!cfg.getIgnoredUnsupportedWarn()) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle(R.string.alert_unsupported_title);
            alert.setMessage(R.string.alert_unsupported_message);
            alert.setCancelable(false);
            alert.setNegativeButton(R.string.alert_exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            alert.setPositiveButton(R.string.alert_ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    cfg.setIgnoredUnsupportedWarn(true);
                    dialog.dismiss();
                }
            });
            alert.create().show();
        }

        if (Utils.marketAvailable(this)) {
            GCMRegistrar.checkDevice(context);
            GCMRegistrar.checkManifest(context);
            final String regId = GCMRegistrar.getRegistrationId(context);
            if (regId.length() != 0) {
                GCMRegistrar.unregister(context);
            }
        }

    } else {
        if (Utils.marketAvailable(this)) {
            GCMRegistrar.checkDevice(context);
            GCMRegistrar.checkManifest(context);
            final String regId = GCMRegistrar.getRegistrationId(context);
            if (regId.length() != 0) {
                if (cfg.upToDate()) {
                    Log.v(Config.LOG_TAG + "GCMRegister", "Already registered");
                } else {
                    Log.v(Config.LOG_TAG + "GCMRegister", "Already registered, out-of-date");
                    cfg.setValuesToCurrent();
                    new AsyncTask<Void, Void, Void>() {
                        @Override
                        protected Void doInBackground(Void... params) {
                            Utils.updateGCMRegistration(context, regId);
                            return null;
                        }
                    }.execute();
                }
            } else {
                GCMRegistrar.register(context, Config.GCM_SENDER_ID);
                Log.v(Config.LOG_TAG + "GCMRegister", "GCM registered");
            }
        } else {
            UpdateCheckReceiver.setAlarm(context);
        }
    }

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_rom), ROMTab.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_kernel), KernelTab.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_walls), WallsTab.class, null);

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

From source file:com.pdj.client.screen.ardoise.ArdoiseNavActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ardoise_nav);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Set up the ViewPager, attaching the adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);

    if (restaurant == null) {
        restaurant = (RestaurantBO) this.getIntent().getSerializableExtra(RestosFragment.RESTO);
    }//from ww  w  .  j  av  a2 s  . co m
    actionBar.setTitle(restaurant.getName());
    final Restaurant resto = Restaurant.newRestaurantWithoutData(restaurant.getId());
    ParseQuery<Ardoise> query = Ardoise.getFullQuery(resto, null, 20);
    query.findInBackground(new FindCallback<Ardoise>() {
        @Override
        public void done(List<Ardoise> ardoises, ParseException e) {
            if (e == null) {

                setArdoises(ardoises);

                if (ardoises.size() == 0) {
                    msgZeroArdoise();
                } else {
                    mArdoiseNavPagerAdapter = new ArdoiseNavPagerAdapter(getSupportFragmentManager(), ardoises);
                    mViewPager.setAdapter(mArdoiseNavPagerAdapter);
                }

            } else {
                showErrorTechnique(e);
            }

        }
    });

}

From source file:fr.tvbarthel.apps.sayitfromthesky.activities.MainActivity.java

/**
 * Set the alpha of the action bar title.
 *
 * @param alpha a value between 0 and 1 that represents the alpha of the action bar title.
 *//* w ww.j  av a2 s.  co m*/
private void setActionBarTitleAlpha(float alpha) {
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        mActionBarTitleColorSpan.setAlpha(alpha);
        mActionBarTitleSpannable.setSpan(mActionBarTitleColorSpan, 0, mActionBarTitleSpannable.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        actionBar.setTitle(mActionBarTitleSpannable);
    }

}

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

void configureActionBarView() {

    if (mScreenName != null) {

        final ActionBar actionBar = getActionBar();
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle("@" + mScreenName);

        final LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        final int layout = R.layout.profile_title_thin;
        /*//from   w ww .  j  a  v a  2s .  com
         * // TODO: This is messy, and likely won't work for large screen
         * devices. Need to come up with a better solution int layout; if
         * (getResources().getConfiguration().orientation ==
         * Configuration.ORIENTATION_LANDSCAPE) { layout=
         * R.layout.profile_title_thin; } else { layout =
         * R.layout.profile_title; }
         */

        final View abView = inflator.inflate(layout, null);
        final ImageView verified = (ImageView) abView.findViewById(R.id.verifiedImage);
        verified.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE);

        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(abView);
    }
}

From source file:fr.cph.chicago.activity.BusBoundActivity.java

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

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(this.mBusRouteName + " (" + this.mBound + ")");
    return true;/*from ww  w .ja  v  a2  s .c  o m*/
}