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:org.catnut.fragment.FavoriteFragment.java

@Override
public void onStart() {
    super.onStart();
    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setTitle(getString(R.string.my_favorites));
    actionBar.setIcon(R.drawable.ic_title_favorite);
}

From source file:org.orange.querysystem.CoursesInThisWeekActivity.java

/**
 * /*from w ww  .ja  v  a 2 s  . co  m*/
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void setTitle() {
    TextView currentTime = (TextView) findViewById(R.id.currentTime);
    String title = getString(R.string.curriculum_schedule_in_this_week);
    Integer weekNumber = SettingsActivity.getCurrentWeekNumber(this);
    if (weekNumber != null) {
        title += "(" + getString(R.string.week_of_semester, weekNumber) + ")";
    }
    //3.0?ActionBar3.0currentTime
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        //??
        currentTime.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
        ActionBar mActionBar = getActionBar();
        mActionBar.setTitle(title);
        //????ActionBar
        if (getResources()
                .getConfiguration().orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
            mActionBar.hide();
        }
    } else {
        currentTime.setText(title + "\t\t" + DateFormat.getDateInstance().format(new Date()));
    }
}

From source file:com.lx.minimusic.MainActivity.java

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

    ActionBar actionBar = getActionBar();
    actionBar.setTitle("?");
    actionBar.setIcon(R.mipmap.app_logo2);

    mMyMusicFragment = MyMusicFragment.newInstance();

    mApplication = (MiniMusicApplication) getApplication();

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);//  ww w. j a  va 2 s. c om

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

    changeColor(currentColor);
}

From source file:nz.ac.otago.psyanlab.common.ImportPaleActivity.java

@SuppressLint("NewApi")
@Override/*from  ww  w  .j a va  2s.  co m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mUserDelegate = getIntent().getParcelableExtra(Args.USER_DELEGATE);
    mUserDelegate.init(this);

    setContentView(R.layout.activity_import);

    Resources resources = getResources();
    mFilePickerFragment = (FilePickerFragment) getSupportFragmentManager().findFragmentById(R.id.file_picker);
    if (savedInstanceState == null) {
        mFilePickerFragment.setRootDir(Environment.getExternalStorageDirectory());
        mFilePickerFragment.setColumnWidth(resources.getDimensionPixelSize(R.dimen.grid_column_width));
        mFilePickerFragment.setNumColumns(StickyGridHeadersGridView.AUTO_FIT);
        mFilePickerFragment.setMultiSelectEnabled(true);
    }
    ActionBar abs = getActionBar();
    abs.setDisplayUseLogoEnabled(false);
    abs.setDisplayShowHomeEnabled(false);
    abs.setTitle(R.string.title_import);
    // startActionMode(this);
}

From source file:org.orange.querysystem.PostsActivity.java

@TargetApi(11)
@Override//from   w w w . j  a  va 2 s .co  m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_tabs_pager);
    currentTime = (TextView) findViewById(R.id.currentTime);
    currentTime.setText(R.string.post);

    mWebUpdaterToDB = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? new PostUpdater(this)
            : new PostUpdater(this) {
                @Override
                public boolean updatePosts(boolean mandatorily) {
                    boolean isUpdating = super.updatePosts(mandatorily);
                    if (isUpdating) {
                        startRefreshAnimation();
                    }
                    return isUpdating;
                }
            };
    mWebUpdaterToDB.setOnPostExecuteListener(new OnPostUpdateListener() {
        @Override
        public void onPostUpdate(long numberOfInsertedPosts, boolean mandatorily) {
            if (mandatorily || numberOfInsertedPosts > 0) {
                if (numberOfInsertedPosts > 0) {
                    reloadPosts();
                    String message = PostsActivity.this.getResources().getString(R.string.has_updated_posts,
                            numberOfInsertedPosts);
                    Toast.makeText(PostsActivity.this, message, Toast.LENGTH_SHORT).show();
                } else if (numberOfInsertedPosts == 0) {
                    Toast.makeText(PostsActivity.this, R.string.no_new_post, Toast.LENGTH_SHORT).show();
                } else //numberOfInsertedPosts < 0
                {
                    Toast.makeText(PostsActivity.this, R.string.fail_to_update_post, Toast.LENGTH_SHORT).show();
                }
            }

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                stopRefreshAnimation();
            }
        }
    });
    if (mWebUpdaterToDB.updatePostsAutomatically()) {
        Toast.makeText(this, R.string.start_to_update_post_automatically, Toast.LENGTH_SHORT).show();
    }

    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();

    mViewPager = (ViewPager) findViewById(R.id.pager);

    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    //3.0ActionBar
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar mActionBar = getActionBar();
        mActionBar.setTitle(R.string.post);
        currentTime.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
        //????ActionBar
        if (getResources()
                .getConfiguration().orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
            mActionBar.hide();
        }
    }
    loadPosts();
}

From source file:com.commonsware.cwac.cam2.support.ConfirmationFragment.java

@Override
public void onHiddenChanged(boolean isHidden) {
    super.onHiddenChanged(isHidden);

    if (!isHidden) {
        ActionBar ab = getActivity().getActionBar();

        ab.setBackgroundDrawable(//from   ww w.j  a  v a 2s.c  o m
                getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_translucent));
        ab.setTitle("");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ab.setDisplayHomeAsUpEnabled(true);
            ab.setHomeAsUpIndicator(R.drawable.cwac_cam2_ic_close_white);
        } else {
            ab.setIcon(R.drawable.cwac_cam2_ic_close_white);
            ab.setDisplayShowHomeEnabled(true);
            ab.setHomeButtonEnabled(true);
        }
    }
}

From source file:com.tweetlanes.android.view.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    mSearchTerm = getIntent().getStringExtra("query");
    if (mSearchTerm == null) {
        Uri data = getIntent().getData();
        if (data != null) {
            mSearchTerm = data.toString().replace("com.tweetlanes.android.search://", "");
        }/*from w  w w  . j av a  2 s .  c  o m*/
    }

    super.onCreate(savedInstanceState);

    // This could be true if loading back into the app from Multitasking
    if (mSearchTerm == null) {
        restartApp();
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(getString(R.string.action_bar_search_title) + " \"" + mSearchTerm + "\"");
    actionBar.setDisplayHomeAsUpEnabled(true);

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

From source file:com.shafiq.mytwittle.view.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    mSearchTerm = getIntent().getStringExtra("query");
    if (mSearchTerm == null) {
        Uri data = getIntent().getData();
        if (data != null) {
            mSearchTerm = data.toString().replace("com.shafiq.mytwittle.search://", "");
        }/*from  www  .  jav  a2s . c o  m*/
    }

    super.onCreate(savedInstanceState);

    // This could be true if loading back into the app from Multitasking
    if (mSearchTerm == null) {
        restartApp();
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(getString(R.string.action_bar_search_title) + " \"" + mSearchTerm + "\"");
    actionBar.setDisplayHomeAsUpEnabled(true);

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

From source file:com.trin.nilmobile.imageloader.ImagePagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_image_pager);

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("");

    Bundle bundle = getIntent().getExtras();
    assert bundle != null;
    String[] imageUrls = bundle.getStringArray(Extra.IMAGES);
    int pagerPosition = bundle.getInt(Extra.IMAGE_POSITION, 0);

    if (savedInstanceState != null) {
        pagerPosition = savedInstanceState.getInt(STATE_POSITION);
    }//from  w  w w.jav  a  2s .c o m

    options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_empty)
            .showImageOnFail(R.drawable.ic_error).resetViewBeforeLoading(true).cacheOnDisk(true)
            .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter(imageUrls));
    pager.setCurrentItem(pagerPosition);
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {

    mSearchTerm = getIntent().getStringExtra("query");
    if (mSearchTerm == null) {
        Uri data = getIntent().getData();
        if (data != null) {
            mSearchTerm = data.toString().replace("com.tweetlanes.android.core.search://", "");
        }/*from  www.j  a va2 s.com*/
    }

    super.onCreate(savedInstanceState);

    // This could be true if loading back into the app from Multitasking
    if (mSearchTerm == null) {
        restartApp();
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(getString(R.string.action_bar_search_title) + " \"" + mSearchTerm + "\"");
    actionBar.setDisplayHomeAsUpEnabled(true);

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