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.deange.textfaker.ui.activity.MessageActivity.java

private void setupActionBar() {
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);

        if (mConversation != null) {
            actionBar.setTitle(mConversation.getName());
            actionBar.setSubtitle(mConversation.getNumber());
        }/*ww w .  j a v a 2s.c om*/
    }
}

From source file:com.burntout.burntout.SendReportActivity.java

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

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

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

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

    Log.d("email", email);

    frontText = (TextView) findViewById(R.id.frontText);
    backText = (TextView) findViewById(R.id.backText);
    reportedLightsCheck = (TextView) findViewById(R.id.reported_lights_text);
    reportPlateNumber = (EditText) findViewById(R.id.report_plate_number);
    message = (EditText) findViewById(R.id.extra_message);
    submitBtn = (Button) findViewById(R.id.report_button);
    pageMarkers = (PageMarkers) findViewById(R.id.pageMarkersReport);
    pageMarkers.setTotalPages(4);/*from w ww . j a v  a 2  s.  co  m*/
    pageMarkers.makeView(0);

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

    reportables = (TappablesHSV) findViewById(R.id.tappablesHSV1);
    reportables.setCommunicator(this);
    reportables.initItems(this);
    reportables.setFeatureItems();
    reportables.addManagers(this);

    reportPlateNumber.clearFocus();
    message.clearFocus();

    addListenerOnSubmit();

}

From source file:com.scto.filerenamer.FileRenamerActivity.java

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

    mSettings = Prefs.getSharedPreferences(this);
    mSettings.registerOnSharedPreferenceChangeListener(this);

    if (Prefs.getThemeType(this) == false) {
        mThemeId = R.style.AppTheme_Light;
        setTheme(mThemeId);//from  w ww.jav a  2  s  .  c o m
    } else {
        mThemeId = R.style.AppTheme_Dark;
        setTheme(mThemeId);
    }

    ActionBar mActionBar = getActionBar();
    if (mActionBar != null) {
        mActionBar.setDisplayHomeAsUpEnabled(true);
        mActionBar.setDisplayShowHomeEnabled(true);
        mActionBar.setDisplayShowTitleEnabled(true);
        mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    } else {
        if (BuildConfig.DEBUG) {
            Log.w("[" + TAG + "]", "mActionBar == null");
        }
    }

    setContentView(R.layout.fragment_tabs_pager);

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

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

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

    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.addNumber)).setIndicator(getString(R.string.addNumber)),
            AddNumbersFragment.class, null);
    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.addCustom)).setIndicator(getString(R.string.addCustom)),
            AddCustomFragment.class, null);
    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.addDate)).setIndicator(getString(R.string.addDate)),
            AddCharsFragment.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.findAndReplace))
            .setIndicator(getString(R.string.findAndReplace)), AddDateFragment.class, null);
    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.removeChars)).setIndicator(getString(R.string.removeChars)),
            RemoveCharsFragment.class, null);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name));
    } else {
        if (BuildConfig.DEBUG) {
            Log.w("[" + TAG + "]", "onCreate( savedInstanceState ) : extras == null");
        }
        this.setTitle(" :: " + getString(R.string.app_name));
    }

    if (savedInstanceState != null) {
        mActionBar.setSelectedNavigationItem(savedInstanceState.getInt("action_bar_tab", 0));
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab_host"));
    }
}

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

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

    // Get and initialise user delegate.
    if (getIntent().hasExtra(Args.USER_DELEGATE)) {
        mUserDelegate = getIntent().getParcelableExtra(Args.USER_DELEGATE);
        mUserDelegate.init(this);
    } else {//from  w ww .  j  a  va 2 s . c o m
        throw new IllegalStateException("User delegate must be provided.");
    }

    // Initialise action bar.
    ActionBar actionBar = getActionBar();
    String title = mUserDelegate.getUserName();
    if (TextUtils.isEmpty(title)) {
        title = getString(R.string.app_name);
        actionBar.setDisplayHomeAsUpEnabled(false);
    } else {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    actionBar.setTitle(title);

    // Initialise fragments.
    FragmentManager fm = getSupportFragmentManager();

    // List fragment.
    mPaleListFragment = (PaleListFragment) fm.findFragmentById(R.id.pale_list_fragment);
    mPaleListFragment.setUserDelegate(mUserDelegate);
    mPaleListFragment.setActivateOnItemClick(true);
    // if (savedInstanceState == null) {
    // mPaleListFragment.setActivatedPosition(0);
    // }

    // Detail fragment.
    mPaleDetailFragment = (PaleDetailFragment) fm.findFragmentById(R.id.pale_detail_fragment);
    if (savedInstanceState != null) {
        updateExperimentDelegate(
                savedInstanceState.<UserExperimentDelegateI>getParcelable(Args.USER_EXPERIMENT_DELEGATE));
    }

    // Initialise sliding container.
    mSlidingContainer = (SlidingPaneLayout) findViewById(R.id.sliding_container);
    mSlidingContainer
            .setParallaxDistance((int) getResources().getDimension(R.dimen.sliding_container_parallax));
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            if (mSlidingContainer.isSlideable()) {
                mSlidingContainer.setShadowResource(R.drawable.opal_list_background);
                mSlidingContainer.invalidate();
            } else {
                mSlidingContainer.setShadowResource(R.drawable.opal_list_background_flat);
                mSlidingContainer.invalidate();
            }
        }
    }, 100);
}

From source file:itkach.aard2.ArticleCollectionActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_PROGRESS);
    setContentView(R.layout.activity_article_collection_loading);
    final Application app = (Application) getApplication();
    app.push(this);
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setSubtitle("...");
    final Intent intent = getIntent();
    final int position = intent.getIntExtra("position", 0);

    AsyncTask<Void, Void, ArticleCollectionPagerAdapter> createAdapterTask = new AsyncTask<Void, Void, ArticleCollectionPagerAdapter>() {

        @Override/*from   w ww  . ja  v a  2  s  . c o m*/
        protected ArticleCollectionPagerAdapter doInBackground(Void... params) {
            ArticleCollectionPagerAdapter result;
            Uri articleUrl = intent.getData();
            if (articleUrl != null) {
                result = createFromUri(app, articleUrl);
            } else {
                String action = intent.getAction();
                if (action == null) {
                    result = createFromLastResult(app);
                } else if (action.equals("showRandom")) {
                    result = createFromRandom(app);
                } else if (action.equals("showBookmarks")) {
                    result = createFromBookmarks(app);
                } else if (action.equals("showHistory")) {
                    result = createFromHistory(app);
                } else {
                    result = createFromIntent(app, intent);
                }
            }
            return result;
        }

        @Override
        protected void onPostExecute(ArticleCollectionPagerAdapter adapter) {
            if (isFinishing() || onDestroyCalled) {
                return;
            }
            articleCollectionPagerAdapter = adapter;
            if (articleCollectionPagerAdapter == null || articleCollectionPagerAdapter.getCount() == 0) {
                Toast.makeText(ArticleCollectionActivity.this, R.string.article_collection_nothing_found,
                        Toast.LENGTH_SHORT).show();
                finish();
                return;
            }

            if (position > articleCollectionPagerAdapter.getCount() - 1) {
                Toast.makeText(ArticleCollectionActivity.this,
                        R.string.article_collection_selected_not_available, Toast.LENGTH_SHORT).show();
                finish();
                return;
            }

            setContentView(R.layout.activity_article_collection);

            findViewById(R.id.pager_title_strip).setVisibility(
                    articleCollectionPagerAdapter.getCount() == 1 ? ViewGroup.GONE : ViewGroup.VISIBLE);

            viewPager = (ViewPager) findViewById(R.id.pager);
            viewPager.setAdapter(articleCollectionPagerAdapter);
            viewPager.setOnPageChangeListener(new OnPageChangeListener() {

                @Override
                public void onPageScrollStateChanged(int arg0) {
                }

                @Override
                public void onPageScrolled(int arg0, float arg1, int arg2) {
                }

                @Override
                public void onPageSelected(final int position) {
                    updateTitle(position);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            ArticleFragment fragment = (ArticleFragment) articleCollectionPagerAdapter
                                    .getItem(position);
                            fragment.applyTextZoomPref();
                        }
                    });

                }
            });
            viewPager.setCurrentItem(position);

            PagerTitleStrip titleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
            titleStrip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
            updateTitle(position);
            articleCollectionPagerAdapter.registerDataSetObserver(new DataSetObserver() {
                @Override
                public void onChanged() {
                    if (articleCollectionPagerAdapter.getCount() == 0) {
                        finish();
                    }
                }
            });
        }
    };

    createAdapterTask.execute();

}

From source file:com.android.packageinstaller.permission.ui.PermissionAppsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setLoading(true /* loading */, false /* animate */);
    setHasOptionsMenu(true);/*from w  w  w. j a  v a  2s.  c om*/
    final ActionBar ab = getActivity().getActionBar();
    if (ab != null) {
        ab.setDisplayHomeAsUpEnabled(true);
    }
    mLauncherPkgs = Utils.getLauncherPackages(getContext());

    String groupName = getArguments().getString(Intent.EXTRA_PERMISSION_NAME);
    mPermissionApps = new PermissionApps(getActivity(), groupName, this);
    mPermissionApps.refresh(true);
}

From source file:info.ipeanut.googletrainingcoursedemos.displayingbitmaps.ui.ImageDetailActivity.java

@TargetApi(VERSION_CODES.HONEYCOMB)
@Override//from w ww .j  a 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);
    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 (null == actionBar) {
            return;
        }
        // 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.mms.rcs.FavoriteDetailActivity.java

private void initUi() {
    setProgressBarIndeterminateVisibility(true);

    mScaleDetector = new ScaleGestureDetector(this, new MyScaleListener());

    if (mCursor != null && mCursor.moveToFirst()) {
        mPagerAdapter = new FavoriteDetailAdapter(this, mCursor);
        mPagerAdapter.setScaleTextList(mSlidePaperItemTextViews);
        mContentPager = (ViewPager) findViewById(R.id.details_view_pager);
        mContentPager.setAdapter(mPagerAdapter);
        mContentPager.setCurrentItem(mCursor.getPosition());
    }/*  w  w  w . j  a va  2s.  c  o m*/

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
}

From source file:com.appmanager.android.app.DetailActivity.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setupActionBar() {
    if (VersionUtils.isEqualOrHigherThanHoneycomb()) {
        ActionBar ab = getActionBar();
        if (ab == null) {
            return;
        }//w  w  w .j  a va2 s  .  c om
        if (VersionUtils.isEqualOrHigherThanIceCreamSandwich()) {
            ab.setHomeButtonEnabled(true);
        }
        ab.setDisplayHomeAsUpEnabled(true);
    }
}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collection_demo);

    lDayFragments = new ArrayList<DayFragment>();

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        String sPosition = extras.getString("POSITION");
        Integer oiPosition = new Integer(sPosition);
        iCurrentPos = oiPosition.intValue();
    }/*ww w  . j a v a 2 s.c om*/

    List<SubjectDb> lSubjectDb = Session.getSingleInstance().getDatabaseHandler().getSubjects();

    for (int i = 0; i < lSubjectDb.size(); i++) {
        DayFragment dayF = new DayFragment();

        Bundle args = new Bundle();
        args.putInt(DayFragment.ARG_POSITION, i);
        dayF.setArguments(args);

        lDayFragments.add(dayF);

    }

    // Navigation onOptionsItemSelected
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

}