Example usage for android.app ActionBar setDisplayHomeAsUpEnabled

List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled

Introduction

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

Prototype

public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);

Source Link

Document

Set whether home should be displayed as an "up" affordance.

Usage

From source file:io.github.sunggu.searchimage.ui.ImageDetailActivity.java

@TargetApi(VERSION_CODES.HONEYCOMB)
@Override/*www . 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.getInstance().getCount());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    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();
        if (actionBar != null) {
            // 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.actionbarsherlock.sample.styled.MainActivityICS.java

/** Called when the activity is first created. */
@Override// w  ww.j a  v  a 2 s .  c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_PROGRESS);

    setContentView(R.layout.main);
    final ActionBar ab = getActionBar();

    // set defaults for logo & home up
    ab.setDisplayHomeAsUpEnabled(showHomeUp);
    ab.setDisplayUseLogoEnabled(useLogo);

    // set up tabs nav
    for (int i = 1; i < 4; i++) {
        ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this));
    }

    // set up list nav
    ab.setListNavigationCallbacks(
            ArrayAdapter.createFromResource(ab.getThemedContext(), R.array.sections,
                    android.R.layout.simple_spinner_dropdown_item),
            //              .createFromResource(this, R.array.sections,
            //                      android.R.layout.simple_spinner_dropdown_item),
            new OnNavigationListener() {
                @Override
                public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                    // FIXME add proper implementation
                    //rotateLeftFrag();
                    return false;
                }
            });

    // default to tab navigation
    showTabsNav();

    // create a couple of simple fragments as placeholders
    //        final int MARGIN = 16;
    //        leftFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN);
    //        rightFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN,
    //                MARGIN);
    //
    //        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    //        ft.add(R.id.root, leftFrag);
    //        ft.add(R.id.root, rightFrag);
    //        ft.commit();

    ((Button) findViewById(R.id.start)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMode = startActionMode(new AnActionModeOfEpicProportions());
        }
    });
    ((Button) findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMode != null) {
                mMode.finish();
            }
        }
    });

    ((Button) findViewById(R.id.progress)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mProgress == 100) {
                mProgress = 0;
                mProgressRunner.run();
            }
        }
    });

}

From source file:com.simplelife.seeds.android.utils.gridview.gridviewui.ImageDetailActivity.java

@TargetApi(11)
@Override/* ww  w  . j  av a 2 s.  c om*/
public void onCreate(Bundle savedInstanceState) {
    /*
    if (BuildConfig.DEBUG) {
    Utils.enableStrictMode();
    }*/
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_seeds_gridview_detailpager);

    // 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,
            SeedsDefinitions.SEEDS_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, "DETAILTAG");
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    //mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length);
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.getSeedsEntity().getPicLinks().size());
    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
        if (null != actionBar) {
            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.tweetlanes.android.view.TweetSpotlightActivity.java

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

    String statusIdAsString = getIntent().getStringExtra(STATUS_ID_KEY);
    if (statusIdAsString != null) {
        long statusId = Long.parseLong(statusIdAsString);

        mGetStatusCallback = TwitterManager.get().getFetchStatusInstance().new FinishedCallback() {
            @Override//from w w  w  . j  a v  a 2  s.  c  o m
            public void finished(TwitterFetchResult result, TwitterStatus status) {
                // TODO: handle error properly
                if (result.isSuccessful() && status != null) {
                    if (mTweetSpotlightAdapter != null) {
                        onGetStatus(status);
                    }
                } else {
                    finish();
                }
                mGetStatusCallback = null;
            }
        };

        // TODO: Look at using a cached value
        TwitterManager.get().getStatus(statusId, mGetStatusCallback);

    } else {
        finish();
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

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

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

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

    String statusIdAsString = getIntent().getStringExtra(STATUS_ID_KEY);
    if (statusIdAsString != null) {
        long statusId = Long.parseLong(statusIdAsString);

        mGetStatusCallback = TwitterManager.get().getFetchStatusInstance().new FinishedCallback() {

            @Override/*from   w w w. j  a  v a  2 s. co  m*/
            public void finished(TwitterFetchResult result, TwitterStatus status) {
                // TODO: handle error properly
                if (result.isSuccessful() && status != null) {
                    if (mTweetSpotlightAdapter != null) {
                        onGetStatus(status);
                    }
                } else {
                    finish();
                }
                mGetStatusCallback = null;
            }
        };

        // TODO: Look at using a cached value
        TwitterManager.get().getStatus(statusId, mGetStatusCallback);

    } else {
        finish();
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

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

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

void configureActionBarView() {

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(getString(R.string.dm_title) + getOtherUserScreenName());
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
}

From source file:com.tcity.android.ui.overview.buildconfiguration.BuildConfigurationOverviewActivity.java

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

    myRecreating = false;//  w w  w  . j a va2s. c o  m
    myBuildConfigurationId = getIntent().getStringExtra(ID_INTENT_KEY);

    setContentView(R.layout.overview_ui);

    ActionBar bar = getActionBar();
    if (bar != null) {
        bar.setTitle(calculateTitle());
        bar.setSubtitle(calculateSubtitle());
        bar.setDisplayHomeAsUpEnabled(true);
    }

    updateSyncBound();

    myLayout = (SwipeRefreshLayout) findViewById(R.id.overview_srlayout);
    myLayout.setColorSchemeResources(R.color.green, R.color.red);
    myLayout.setOnRefreshListener(this);

    myEngine = calculateEngine();
    setListAdapter(myEngine.getAdapter());
}

From source file:com.kosbrother.houseprice.ActionBarTabs.java

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

    setContentView(R.layout.action_bar_tabs);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // actionBar.setDisplayShowTitleEnabled(false);
    if (Build.VERSION.SDK_INT >= 14) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }/*from   w ww .j  av  a2  s . c  o  m*/
    actionBar.addTab(actionBar.newTab().setText("")
            .setTabListener(new TabListener("http://m.yungching.com.tw/", "YungChing")));
    actionBar.addTab(actionBar.newTab().setText("")
            .setTabListener(new TabListener("http://m.sinyi.com.tw/", "SinYi")));
    actionBar.addTab(actionBar.newTab().setText("591")
            .setTabListener(new TabListener("http://m.591.com.tw/mobile-index.html?f=app", "591")));
    CallAds();

}

From source file:com.cypress.cysmart.CommonFragments.NavigationDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation
 * drawer interactions.//from  ww  w.  j a va  2  s.  c  o  m
 *
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 */
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // set a custom shadow that overlays the main content when the drawer
    // opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_launcher, /* NavigationDrawer image to replace 'Up' caret */
            R.string.navigation_drawer_open, /*
                                             * "open drawer" description for
                                             * accessibility
                                             */
            R.string.navigation_drawer_close /*
                                             * "close drawer" description for
                                             * accessibility
                                             */
    ) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }

            getActivity().invalidateOptionsMenu(); // calls
            // onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }

            getActivity().invalidateOptionsMenu(); // calls
            // onPrepareOptionsMenu()
        }
    };

    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

From source file:fm.krui.kruifm.KRUIScheduleActivity.java

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

    // Enable back button in this activity
    ActionBar actionbar = getActionBar();
    actionbar.setDisplayHomeAsUpEnabled(true);
    actionbar.setSubtitle("Our 7 Day Program Schedule");

    showLoadingScreen(true);/*from w  ww  . j av a2 s  .  c om*/
    cal = new GregorianCalendar();

    // Download show data
    downloadShowData();
}