Example usage for android.app ActionBar setDisplayShowTitleEnabled

List of usage examples for android.app ActionBar setDisplayShowTitleEnabled

Introduction

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

Prototype

public abstract void setDisplayShowTitleEnabled(boolean showTitle);

Source Link

Document

Set whether an activity title/subtitle should be displayed.

Usage

From source file:ntq.lbs.imagelazyloading.ui.ImageDetailActivity.java

@TargetApi(VERSION_CODES.HONEYCOMB)
@Override/*from   w  w  w . j ava  2 s  . c o  m*/
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail_pager);

    // Fetch screen height and width, to use as our max size when loading images as this
    // activity runs full screen
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    // For this sample we'll use half of the longest width to resize our images. As the
    // image scaling ensures the image is larger than this, we should be left with a
    // resolution that is appropriate for both portrait and landscape. For best image quality
    // we shouldn't divide by 2, but this will use more memory and require a larger memory
    // cache.
    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of app memory

    // The ImageFetcher takes care of loading images into our ImageView children asynchronously
    mImageFetcher = new ImageFetcher(this, longest);
    mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin));
    mPager.setOffscreenPageLimit(2);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to create a more
    // immersive photo viewing experience
    if (Utils.hasHoneycomb()) {
        final ActionBar actionBar = getActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                } else {
                    actionBar.show();
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity
    final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1);
    if (extraCurrentItem != -1) {
        mPager.setCurrentItem(extraCurrentItem);
    }
}

From source file:sample.hawk.com.mybasicappcomponents.data_structure.cache.DisplayingBitmaps.ui.ImageDetailActivity.java

@TargetApi(VERSION_CODES.HONEYCOMB)
@Override//from  ww  w  . j a v a  2 s  .  c  o  m
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail_pager);

    // Fetch screen height and width, to use as our max size when loading images as this
    // activity runs full screen
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    // For this sample we'll use half of the longest width to resize our images. As the
    // image scaling ensures the image is larger than this, we should be left with a
    // resolution that is appropriate for both portrait and landscape. For best image quality
    // we shouldn't divide by 2, but this will use more memory and require a larger memory
    // cache.
    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of app memory

    // The ImageFetcher takes care of loading images into our ImageView children asynchronously
    mImageFetcher = new ImageFetcher(this, longest);
    mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mPager.setPageMargin(64);
    mPager.setOffscreenPageLimit(2);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to create a more
    // immersive photo viewing experience
    if (Utils.hasHoneycomb()) {
        final ActionBar actionBar = getActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                } else {
                    actionBar.show();
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity
    final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1);
    if (extraCurrentItem != -1) {
        mPager.setCurrentItem(extraCurrentItem);
    }
}

From source file:vn.cybersoft.obs.android.activities.DummyActivity.java

public void setActionBar() {
    ActionBar mActionBar = getActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);

    LayoutInflater mInflater = LayoutInflater.from(this);
    View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);

    TextView tvAppName = (TextView) mCustomView.findViewById(R.id.tvAppName);
    tvAppName.setText("Droid Battery Booster");

    ImageButton ivSearch = (ImageButton) mCustomView.findViewById(R.id.ivSearch);
    ivSearch.setOnClickListener(new OnClickListener() {

        @Override/*w w  w  .ja  v  a 2 s  . c  om*/
        public void onClick(View view) {
            // slide_me.toggleRightDrawer();
        }
    });

    ImageView ivdrawer = (ImageView) mCustomView.findViewById(R.id.ivdrawer);
    ivdrawer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            // slide_me.toggleLeftDrawer();
            if (flag) {
                mDrawerLayout.openDrawer(Gravity.LEFT);
                flag = false;
            } else {
                mDrawerLayout.closeDrawer(Gravity.LEFT);
                flag = true;
            }
        }
    });
    mActionBar.setCustomView(mCustomView);
    mActionBar.setDisplayShowCustomEnabled(true);
}

From source file:uz.sag.sagbuyurtmalari.sagbuyurtmalari.ui.ImageDetailActivity.java

@TargetApi(VERSION_CODES.HONEYCOMB)
@Override//from  ww  w  . ja v  a 2 s  . co m
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail_pager);

    // Fetch screen height and width, to use as our max size when loading images as this
    // activity runs full screen
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    // For this sample we'll use half of the longest width to resize our images. As the
    // image scaling ensures the image is larger than this, we should be left with a
    // resolution that is appropriate for both portrait and landscape. For best image quality
    // we shouldn't divide by 2, but this will use more memory and require a larger memory
    // cache.
    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of app memory

    // The ImageFetcher takes care of loading images into our ImageView children asynchronously
    mImageFetcher = new ImageFetcher(this, longest);
    mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    //@TODO   mPager.setPageMargin((int) getResources().getDimension(R.dimen.horizontal_page_margin));
    mPager.setOffscreenPageLimit(2);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to create a more
    // immersive photo viewing experience
    if (Utils.hasHoneycomb()) {
        final ActionBar actionBar = getActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                } else {
                    actionBar.show();
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity
    final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1);
    if (extraCurrentItem != -1) {
        mPager.setCurrentItem(extraCurrentItem);
    }
}

From source file:activities.PaintingActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setLogo(R.drawable.navbar_logo);
    actionBar.setIcon(R.drawable.ic_drawer);
}

From source file:org.birthdayadapter.ui.BaseActivity.java

/**
 * Called when the activity is first created.
 *//*from   w w  w .  j a  va 2 s .  com*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mActivity = this;

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // Load Activity for Android < 4.0
        Intent oldActivity = new Intent(mActivity, BaseActivityV8.class);
        oldActivity.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(oldActivity);
        finish();
    } else {
        // Load new design with tabs
        mViewPager = new ViewPager(this);
        mViewPager.setId(R.id.pager);

        setContentView(mViewPager);

        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(false);

        mTabsAdapter = new TabsAdapter(this, mViewPager);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_main)), BaseFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_preferences)),
                PreferencesFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_accounts)),
                AccountListFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_help)), HelpFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_about)), AboutFragment.class,
                null);

        // default is disabled:
        mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE);

        mySharedPreferenceChangeListener = new MySharedPreferenceChangeListener(mActivity,
                mBackgroundStatusHandler);

        /*
         * Show workaround dialog for Android bug http://code.google.com/p/android/issues/detail?id=34880
         * Bug exists on Android 4.1 (SDK 16) and on some phones like Galaxy S4
         */
        if (BuildConfig.GOOGLE_PLAY_VERSION && PreferencesHelper.getShowWorkaroundDialog(mActivity)
                && !isPackageInstalled("org.birthdayadapter.jb.workaround")) {
            if ((Build.VERSION.SDK_INT == 16) || Build.DEVICE.toUpperCase().startsWith("GT-I9000")
                    || Build.DEVICE.toUpperCase().startsWith("GT-I9500")) {
                InstallWorkaroundDialogFragment dialog = InstallWorkaroundDialogFragment.newInstance();
                dialog.show(getFragmentManager(), "workaroundDialog");
            }
        }
    }
}

From source file:com.groksolutions.grok.mobile.HourDayWeekActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getResourceView());//ww  w.  j  a v a2  s  .  c om

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);

    Locale l = Locale.getDefault();

    // For each of the sections in the app, add a tab to the action bar.
    // Add the "Fragment" class to the tab's tag. The tab's "Fragment" will
    // be created using this class

    // Hour Page
    actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_hour).toUpperCase(l))
            .setTabListener(this).setTag(AggregationType.Hour));

    // Day Page
    actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_day).toUpperCase(l))
            .setTabListener(this).setTag(AggregationType.Day));

    // Week Page
    actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_week).toUpperCase(l))
            .setTabListener(this).setTag(AggregationType.Week));

    // Create the fragment adapter that will return a fragment based on the
    // Fragment class attached to the tab's tag object
    final FragmentPagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        final Fragment[] _fragments = new Fragment[3];

        @Override
        public Fragment getItem(int position) {
            Tab tab = actionBar.getTabAt(position);
            if (tab != null) {
                if (_fragments[position] == null) {
                    _fragments[position] = createTabFragment(tab);
                }
            }
            return _fragments[position];
        }

        @Override
        public int getCount() {
            return actionBar.getTabCount();
        }
    };

    // Set up the ViewPager with the sections adapter.
    _viewPager = (ViewPager) findViewById(R.id.pager);
    _viewPager.setAdapter(pagerAdapter);

    // Keep all pages in memory
    _viewPager.setOffscreenPageLimit(2);

    // 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.
    _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });
}

From source file:ru.lizaalert.common.ui.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();
    assert actionBar != null;
    actionBar.setDisplayShowTitleEnabled(false);
    //   ?   , ? ?   ,  ? 
    //        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mSectionsPagerAdapter = new SectionsPagerAdapter(this, getFragmentManager());

    Log.d("8800", "mViewPager " + mViewPager);
    Log.d("8800", "mSectionsPagerAdapter " + mSectionsPagerAdapter);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from ww  w. jav  a 2s.  co  m*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            if (position == 1) {
                if (getCurrentFocus() != null) {
                    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                            INPUT_METHOD_SERVICE);
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
                }
            }

        }
    });

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {

        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    if (!Settings.instance(this).isLicenceAccepted()) {
        LicenceDialog licenceDialog = new LicenceDialog();
        licenceDialog.setListener(new LicenceDialog.Listener() {
            @Override
            public void onAcceptLicence(DialogInterface dialog) {
                dialog.dismiss();
                Settings.instance(MainActivity.this).setLicenceAccepted(true);
            }

            @Override
            public void onDeclineLicence(DialogInterface dialog) {
                dialog.dismiss();
                finish();
            }
        });
        licenceDialog.show(this);

    }
}

From source file:ginger.connexus.activity.ImageDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();/*from ww w.  java  2  s  . co m*/
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pager_image_detail);

    // Fetch screen height and width, to use as our max size when loading
    // images as this
    // activity runs full screen
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    // For this sample we'll use half of the longest width to resize our
    // images. As the image scaling ensures the image is larger than this,
    // we should be left with a resolution that is appropriate for both
    // portrait and landscape. For best image quality we shouldn't divide by
    // 2, but this will use more memory and require a larger memory cache.
    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    // Set memory cache to 25% of app memory
    cacheParams.setMemCacheSizePercent(0.25f);

    // The ImageFetcher takes care of loading images into our ImageView
    // children asynchronously
    mImageFetcher = new ImageFetcher(this, longest);
    mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    final List<String> imageUrls = Arrays.asList(getIntent().getStringArrayExtra(EXTRA_IMAGE_URLS));
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), imageUrls);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin));
    mPager.setOffscreenPageLimit(2);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to
    // create a more immersive photo viewing experience
    if (Utils.hasHoneycomb()) {
        final ActionBar actionBar = getActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                } else {
                    actionBar.show();
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity
    final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1);
    if (extraCurrentItem != -1) {
        mPager.setCurrentItem(extraCurrentItem);
    }
}

From source file:com.schedule.ScheduleActivity.java

/**
 * Sets up Action Bar (if present).//  w  ww . jav a2s. c om
 * 
 * @param showTabs
 *            whether to show tabs (if false, will show list).
 * @param selTab
 *            the selected tab or list item.
 */
public void setUpActionBar(boolean showTabs, int selTab) {
    if (Build.VERSION.SDK_INT < 11) {
        // No action bar for you!
        // But do not despair. In this case the layout includes a bar across
        // the
        // top that looks and feels like an action bar, but is made up of
        // regular views.
        return;
    }

    android.app.ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);

    // Set up a CompatActionBarNavHandler to deliver us the Action Bar
    // nagivation events
    CompatActionBarNavHandler handler = new CompatActionBarNavHandler(this);
    if (showTabs) {
        actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
        int i;
        for (i = 0; i < MENUS.length; i++) {
            actionBar.addTab(actionBar.newTab().setText(MENUS[i]).setTabListener(handler));
        }
        actionBar.setSelectedNavigationItem(selTab);
    } else {
        actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
        SpinnerAdapter adap = new ArrayAdapter<String>(this, R.layout.actionbar_list_item, MENUS);
        actionBar.setListNavigationCallbacks(adap, handler);
    }

    // Show logo instead of icon+title.
    actionBar.setDisplayUseLogoEnabled(true);
}