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.aniruddhc.acemusic.player.NowPlayingQueueActivity.NowPlayingQueueActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    mContext = this;
    sharedPreferences = getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE);

    //Get the screen's parameters.
    DisplayMetrics displayMetrics = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int screenWidth = displayMetrics.widthPixels;

    //Set the UI theme.
    if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_THEME")
            || sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME")
                    .equals("DARK_CARDS_THEME")) {
        setTheme(R.style.AppTheme);//from  w ww .  j a  va  2  s .com
    } else {
        setTheme(R.style.AppThemeLight);
    }

    super.onCreate(savedInstanceState);

    if (getOrientation().equals("PORTRAIT")) {

        //Finish this activity and relaunch the activity that called this one.
        Intent intent = new Intent(this, (Class<?>) getIntent().getSerializableExtra("CALLING_CLASS"));
        intent.putExtras(getIntent());
        intent.putExtra("NEW_PLAYLIST", false);
        intent.putExtra("CALLED_FROM_FOOTER", true);
        intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        finish();
        startActivity(intent);

        return;

    } else {

        setContentView(R.layout.activity_now_playing_queue);

        final Fragment nowPlayingQueueFragment = new NowPlayingQueueFragment();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.now_playing_queue_container, nowPlayingQueueFragment, "nowPlayingQueueFragment");
        transaction.commit();

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

        // Update the action bar title with the TypefaceSpan instance.
        ActionBar actionBar = getActionBar();
        actionBar.setTitle(s);
        actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.holo_gray_selector));

    }

}

From source file:com.Duo.music.player.NowPlayingQueueActivity.NowPlayingQueueActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    mContext = this;
    sharedPreferences = getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);

    //Get the screen's parameters.
    DisplayMetrics displayMetrics = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int screenWidth = displayMetrics.widthPixels;

    //Set the UI theme.
    if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_THEME")
            || sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME")
                    .equals("DARK_CARDS_THEME")) {
        setTheme(R.style.AppTheme);//from  www.  j a v a  2 s.c o m
    } else {
        setTheme(R.style.AppThemeLight);
    }

    super.onCreate(savedInstanceState);

    if (getOrientation().equals("PORTRAIT")) {

        //Finish this activity and relaunch the activity that called this one.
        Intent intent = new Intent(this, (Class<?>) getIntent().getSerializableExtra("CALLING_CLASS"));
        intent.putExtras(getIntent());
        intent.putExtra("NEW_PLAYLIST", false);
        intent.putExtra("CALLED_FROM_FOOTER", true);
        intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        finish();
        startActivity(intent);

        return;

    } else {

        setContentView(R.layout.activity_now_playing_queue);

        final Fragment nowPlayingQueueFragment = new NowPlayingQueueFragment();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.now_playing_queue_container, nowPlayingQueueFragment, "nowPlayingQueueFragment");
        transaction.commit();

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

        // Update the action bar title with the TypefaceSpan instance.
        ActionBar actionBar = getActionBar();
        actionBar.setTitle(s);
        actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.holo_gray_selector));

    }

}

From source file:com.jelly.music.player.NowPlayingQueueActivity.NowPlayingQueueActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    mContext = this;
    sharedPreferences = getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE);

    //Get the screen's parameters.
    DisplayMetrics displayMetrics = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int screenWidth = displayMetrics.widthPixels;

    //Set the UI theme.
    if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_THEME")
            || sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME")
                    .equals("DARK_CARDS_THEME")) {
        setTheme(R.style.AppTheme);//  ww  w.j a v  a  2 s  . c  o  m
    } else {
        setTheme(R.style.AppThemeLight);
    }

    super.onCreate(savedInstanceState);

    if (getOrientation().equals("PORTRAIT")) {

        //Finish this activity and relaunch the activity that called this one.
        Intent intent = new Intent(this, (Class<?>) getIntent().getSerializableExtra("CALLING_CLASS"));
        intent.putExtras(getIntent());
        intent.putExtra("NEW_PLAYLIST", false);
        intent.putExtra("CALLED_FROM_FOOTER", true);
        intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        finish();
        startActivity(intent);

        return;

    } else {

        setContentView(R.layout.activity_now_playing_queue);

        final Fragment nowPlayingQueueFragment = new NowPlayingQueueFragment();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.now_playing_queue_container, nowPlayingQueueFragment, "nowPlayingQueueFragment");
        transaction.commit();

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

        // Update the action bar title with the TypefaceSpan instance.
        ActionBar actionBar = getActionBar();
        actionBar.setTitle(s);
        actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.holo_gray_selector));

    }

}

From source file:com.thedrycake.tempincity.ui.MainActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setTitle(String cityName) {
    CharSequence title;//from w w w  .jav a  2 s . c om
    if (!StringUtils.isNullOrEmpty(cityName)) {
        title = getText(R.string.temp_in) + " " + cityName;
    } else {
        title = getText(R.string.app_name);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final ActionBar actionBar = getActionBar();
        actionBar.setTitle(title);
    } else {
        setTitle(title);
    }
}

From source file:com.android.settings.profiles.SetupTriggersFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final ActionBar actionBar = getActivity().getActionBar();
    if (mNewProfileMode) {
        actionBar.setTitle(R.string.profile_setup_setup_triggers_title);
    } else {/* w  ww.j  ava 2 s  .  c  o m*/
        String title = getString(R.string.profile_setup_setup_triggers_title_config, mProfile.getName());
        actionBar.setTitle(title);
    }
}

From source file:org.mythtv.client.ui.AbstractMythtvFragmentActivity.java

protected void setupActionBar() {
    Log.v(TAG, "setupActionBar : enter");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);

        actionBar.setTitle(getResources().getString(R.string.app_name));
    }// ww w . j  av a 2 s.  c o  m

    Log.v(TAG, "setupActionBar : exit");
}

From source file:com.rw.barcharttest.MainActivity.java

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

    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(R.string.app_name);
    }/*w  ww .ja  v  a 2  s .  c om*/
}

From source file:com.pickr.activities.PhotosPagerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler(this);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_photos_pager);

    ActionBar actionBar = getActionBar();
    actionBar.setTitle(null);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#99333333")));

    mPager = (ViewPager) findViewById(R.id.photosPager);
    mPager.setOnPageChangeListener(this);
    mPager.setPageMargin(10);// w ww  . j  a va 2s . c o m
}

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

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

    activity = this;

    ActionBar bar = getActionBar();
    bar.setTitle(teamNumber != -1 ? "Team " + teamNumber : "All Data");

    //tab for team overview
    ActionBar.Tab teamOverviewTab = bar.newTab();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    teamOverviewTab.setText("All Notes");
    teamOverviewTab.setTag("all");
    teamOverviewTab.setTabListener(this);
    bar.addTab(teamOverviewTab);// w  w  w  .j av  a  2s  . co  m
    bar.setDisplayHomeAsUpEnabled(true);

    //add an actionbar tab for every event the team is competing at
    ArrayList<String> events;
    if (teamNumber == -1) {
        events = StartActivity.db.getAllEventKeys();
    } else {
        Team team = StartActivity.db.getTeam(teamKey);
        events = team.getTeamEvents();
    }
    for (String eventKey : events) {
        Log.d(Constants.LOG_TAG, "Making AB Tab for " + eventKey);
        Event event = StartActivity.db.getEvent(eventKey);
        if (event == null)
            continue;
        ActionBar.Tab eventTab = bar.newTab();
        eventTab.setTag(event.getEventKey());
        eventTab.setText(event.getShortName());
        eventTab.setTabListener(this);
        bar.addTab(eventTab);
    }

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

}

From source file:org.catnut.ui.PluginsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar bar = getActionBar();
    bar.setTitle(R.string.plugins);
    getFragmentManager().addOnBackStackChangedListener(this);
    int which = getIntent().getIntExtra(Constants.ACTION, -1);
    switch (which) {
    case ACTION_ZHIHU_ITEM:
    case ACTION_ZHIHU_PAGER:
        if (savedInstanceState == null) {
            Fragment fragment = which == ACTION_ZHIHU_ITEM
                    ? ZhihuItemFragment.getFragment(getIntent().getLongExtra(Constants.ID, 0L))
                    : PagerItemFragment.getFragment(getIntent().getLongExtra(Constants.ID, 0L),
                            getIntent().getLongExtra(PagerItemFragment.ORDER_ID, 0L));
            getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
        }//from   w ww.  java 2 s. c  o m
        break;
    default:
        injectPager(bar, savedInstanceState);
        break;
    }
    if (CatnutApp.getTingtingApp().getPreferences().getBoolean(getString(R.string.pref_enable_analytics),
            true)) {
        mTracker = EasyTracker.getInstance(this);
    }
}