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: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;
        /*// ww  w .  ja  v a2 s .  c o m
         * // 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:org.rm3l.ddwrt.tiles.status.wireless.WirelessIfaceQrCodeActivity.java

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

    //Show activity as popup
    //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
    //        requestWindowFeature(Window.FEATURE_ACTION_BAR);
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    //        final WindowManager.LayoutParams params = getWindow().getAttributes();
    //        params.height = WindowManager.LayoutParams.WRAP_CONTENT; //fixed height
    //        params.width = WindowManager.LayoutParams.WRAP_CONTENT; //fixed width
    //        params.alpha = 1.0f;
    //        params.dimAmount = 0.5f;
    //        getWindow().setAttributes(params);

    setContentView(R.layout.tile_status_wireless_iface_qrcode);

    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//from  w  w w  .j  ava 2 s  .  c o  m

    final Intent intent = getIntent();
    mRouterUuid = intent.getStringExtra(RouterManagementActivity.ROUTER_SELECTED);
    mSsid = intent.getStringExtra(SSID);
    mWifiQrCodeString = intent.getStringExtra(WIFI_QR_CODE);

    final ImageView qrCodeImageView = (ImageView) findViewById(R.id.tile_status_wireless_iface_qrcode_image);

    final View loadingView = findViewById(R.id.tile_status_wireless_iface_qrcode_image_loading_view);
    loadingView.setVisibility(View.VISIBLE);

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        final Point outSize = new Point();
                        getWindowManager().getDefaultDisplay().getSize(outSize);
                        mBitmap = encodeAsBitmap(mWifiQrCodeString, BarcodeFormat.QR_CODE, outSize.x,
                                outSize.y / 2);
                        qrCodeImageView.setImageBitmap(mBitmap);
                        qrCodeImageView.setVisibility(View.VISIBLE);
                        loadingView.setVisibility(View.GONE);
                        if (optionsMenu != null) {
                            optionsMenu.findItem(R.id.tile_status_wireless_iface_qrcode_share).setEnabled(true);
                        }

                    } catch (final Exception e) {
                        e.printStackTrace();
                        mException = e;
                        Utils.reportException(e);
                        findViewById(R.id.tile_status_wireless_iface_qrcode_image_error)
                                .setVisibility(View.VISIBLE);
                        qrCodeImageView.setVisibility(View.GONE);
                        loadingView.setVisibility(View.GONE);
                        qrCodeImageView.setVisibility(View.GONE);
                        if (optionsMenu != null) {
                            optionsMenu.findItem(R.id.tile_status_wireless_iface_qrcode_share)
                                    .setEnabled(false);
                        }
                    }
                }
            });
        }
    });

    ((TextView) findViewById(R.id.tile_status_wireless_iface_qrcode_ssid)).setText(mSsid);
}

From source file:com.kawunglabs.olimpiadeuiapp.HelpActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_help);
    resources = getResources();/*from   ww  w.  j  a v  a2s  .c  om*/

    // Create an adapter that when requested, will return a fragment representing an object in
    // the collection.
    // 
    // ViewPager and its adapters use support library fragments, so we must use
    // getSupportFragmentManager.
    mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());

    // Set up action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home button should show an "Up" caret, indicating that touching the
    // button will take the user one step up in the application's hierarchy.
    actionBar.setDisplayHomeAsUpEnabled(true);

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

From source file:com.ternup.caddisfly.fragment.NavigationDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 *
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 *//*from  w  ww .j ava 2 s .co m*/
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);
    // set up the drawer's list view with items and click listener

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        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_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.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;
            }

            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

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

    // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }
    // 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:com.burntout.burntout.AddCarActivity.java

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

    ActionBar bar = getActionBar();
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#1E5791")));
    bar.setTitle("Burnt Out");
    bar.setSubtitle("Add Vehicle");
    bar.setDisplayHomeAsUpEnabled(true);

    //adapter = new AutopickerArrayAdapter(this, R.layout.add_car_activity, autopickerValues);

    makeModelEntry = (EditText) findViewById(R.id.make_model);
    plateNumberEntry = (EditText) findViewById(R.id.plate_number);
    pageMarkers = (PageMarkers) findViewById(R.id.pageMarkersAdd);
    pageMarkers.setTotalPages(4);//w  w w  .j a va 2 s .co  m
    pageMarkers.makeView(0);

    Context context = this;

    SharedPreferences sharedPref = context.getSharedPreferences(getString(R.string.pref), Context.MODE_PRIVATE);

    email = sharedPref.getString("email", null);

    vehicleTypeHSV = (VehicleTypeHSV) findViewById(R.id.addVehicleTypeHSV);
    vehicleTypeHSV.setComm(this);
    vehicleTypeHSV.initItems(this);
    vehicleTypeHSV.setFeatureItems();
    vehicleTypeHSV.addManagers(this);

    statePicker = (StatePicker) findViewById(R.id.statepicker_view2);

    submitBtn = (Button) findViewById(R.id.submit_button_addcar);

    addListenerOnSubmit();

}

From source file:com.opensource.bitmaploader.test.ui.ImageDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    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);

    // The ImageWorker takes care of loading images into our ImageView children asynchronously
    //        mPicWorker = new ImageFetcher(this, displaymetrics.widthPixels, displaymetrics.heightPixels);
    mPicWorker = new ImageFetcher(this, getResources().getDisplayMetrics().widthPixels);
    File cachePath = null;/*  w  w  w. j  ava 2  s  .  c om*/
    if (Utils.hasExternalStorage()) {
        File appRoot = new File(Environment.getExternalStorageDirectory(), "BitmapLoader");
        cachePath = new File(appRoot, ".cache");
    }
    ImageCache.ImageCacheParams picCacheParams = new ImageCache.ImageCacheParams(cachePath, IMAGE_CACHE_DIR);
    picCacheParams.memCacheSize = 1024 * 1024 * Utils.getMemoryClass(this) / 3;
    picCacheParams.diskCacheEnabled = true;
    mPicWorker.setAdapter(Images.imageWorkerUrlsAdapter);
    mPicWorker.setImageCache(new ImageCache(this, picCacheParams));
    mPicWorker.setImageFadeIn(false);
    mPicWorker.setLoadingImage(R.drawable.empty_photo);

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(cachePath, THUMB_CACHE_DIR);
    //        ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(cachePath, IMAGE_CACHE_DIR);
    cacheParams.memCacheSize = 1024 * 1024 * Utils.getMemoryClass(this) / 3;
    cacheParams.diskCacheEnabled = false;
    mThumbWorker = new ImageFetcher(this, 150);
    mThumbWorker.setAdapter(Images.imageWorkerUrlsAdapter);
    mThumbWorker.setLoadingImage(R.drawable.empty_photo);
    mThumbWorker.setImageCache(new ImageCache(this, cacheParams));

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), mPicWorker.getAdapter().getSize());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin));

    // 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.hasActionBar()) {
        final ActionBar actionBar = getActionBar();

        if (null != actionBar) {
            // Enable "up" navigation on ActionBar icon and hide title text
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);

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

            // 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();
                    }
                }
            });
        }
    }

    // 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.brkc.traffic.ui.image.ImageDetailActivity.java

@TargetApi(VERSION_CODES.HONEYCOMB)
@Override/*ww w .ja  va  2  s. co  m*/
public void onCreate(Bundle savedInstanceState) {

    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(), ImageListFragment.getImageCount());
    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.android.talkback.TalkBackKeyboardShortcutPreferencesActivity.java

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

    setTitle(getString(R.string.title_pref_manage_keyboard_shortcuts));

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//from   w ww  .j  ava 2s .co m

    TalkBackService talkBackService = TalkBackService.getInstance();
    KeyComboManager keyComboManager = talkBackService == null ? KeyComboManager.create(this)
            : talkBackService.getKeyComboManager();
    TalkBackKeyboardShortcutPreferenceFragment fragment = TalkBackKeyboardShortcutPreferenceFragment
            .createFor(keyComboManager.getKeymap());
    getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
}

From source file:org.digitalcampus.oppia.activity.DownloadActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_download);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }/*w  w w  .  j a  va 2 s  . com*/
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    Bundle bundle = this.getIntent().getExtras();
    if (bundle != null) {
        Tag t = (Tag) bundle.getSerializable(Tag.TAG);
        this.url = MobileLearning.SERVER_TAG_PATH + String.valueOf(t.getId()) + File.separator;
    } else {
        this.url = MobileLearning.SERVER_COURSES_PATH;
        this.showUpdatesOnly = true;
    }

    courses = new ArrayList<CourseIntallViewAdapter>();
    dla = new DownloadCourseListAdapter(this, courses);
    dla.setOnClickListener(new CourseListListener());
    ListView listView = (ListView) findViewById(R.id.tag_list);
    listView.setAdapter(dla);
}

From source file:com.ovte.bitmap_load.ui.ImageDetailActivity.java

@TargetApi(11)
@Override/*w  w w  . ja v a 2s. 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);
    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();
        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);
    }
}