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.codebutler.farebot.activity.AdvancedCardInfoActivity.java

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

    findViewById(R.id.error_button).setOnClickListener(new View.OnClickListener() {
        @Override//from ww  w  . j  a  v  a  2s .  c  o  m
        public void onClick(View v) {
            reportError();
        }
    });

    Serializer serializer = FareBotApplication.getInstance().getSerializer();
    mCard = Card.fromXml(serializer, getIntent().getStringExtra(AdvancedCardInfoActivity.EXTRA_CARD));

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabPagerAdapter(this, viewPager);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mCard.getCardType().toString() + " " + Utils.getHexString(mCard.getTagId(), "<error>"));

    if (mCard.getScannedAt().getTime() > 0) {
        String date = Utils.dateFormat(mCard.getScannedAt());
        String time = Utils.timeFormat(mCard.getScannedAt());
        actionBar.setSubtitle(Utils.localizeString(R.string.scanned_at_format, time, date));
    }

    if (getIntent().hasExtra(EXTRA_ERROR)) {
        mError = (Exception) getIntent().getSerializableExtra(EXTRA_ERROR);
        if (mError instanceof UnsupportedCardException) {
            findViewById(R.id.unknown_card).setVisibility(View.VISIBLE);
        } else if (mError instanceof UnauthorizedException) {
            findViewById(R.id.unauthorized_card).setVisibility(View.VISIBLE);
            findViewById(R.id.load_keys).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    startActivity(new Intent(AdvancedCardInfoActivity.this, AddKeyActivity.class));
                }
            });
        } else {
            findViewById(R.id.error).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.error_text)).setText(Utils.getErrorMessage(mError));
        }
    }

    CardHasManufacturingInfo infoAnnotation = mCard.getClass().getAnnotation(CardHasManufacturingInfo.class);
    if (infoAnnotation == null || infoAnnotation.value()) {
        mTabsAdapter.addTab(actionBar.newTab().setText(R.string.hw_detail), CardHWDetailFragment.class,
                getIntent().getExtras());
    }

    CardRawDataFragmentClass annotation = mCard.getClass().getAnnotation(CardRawDataFragmentClass.class);
    if (annotation != null) {
        Class rawDataFragmentClass = annotation.value();
        if (rawDataFragmentClass != null) {
            mTabsAdapter.addTab(actionBar.newTab().setText(R.string.data), rawDataFragmentClass,
                    getIntent().getExtras());
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        }
    }
}

From source file:com.abourazanis.muzei.wallbase.WallhavenSettings.java

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

    setContentView(R.layout.wallbase_settings);

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

    mUpdateIntervalSpinner = (Spinner) findViewById(R.id.spUpdateInterval);

    mChkSafe = (CheckBox) findViewById(R.id.chkSafe);
    mChkSketchy = (CheckBox) findViewById(R.id.chkSketchy);
    mChkAnime = (CheckBox) findViewById(R.id.chkAnime);
    mChkGeneral = (CheckBox) findViewById(R.id.chkGeneral);
    mChkPeople = (CheckBox) findViewById(R.id.chkPeople);
    mChkUpdateOnWifiOnly = (CheckBox) findViewById(R.id.chkUpdateOnWifiOnly);

    setupIntervalSpinner();//from  w  w w.  j  a v a  2s.  c o m
    setCheckboxes();

}

From source file:com.android.calculator2.StoreActivity.java

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

    // Update theme (as needed)
    Theme.buildResourceMap(com.android.calculator2.R.class);
    Theme.setPackageName(CalculatorSettings.getTheme(getContext()));
    int customTheme = Theme.getSettingsTheme(this);
    if (customTheme != 0) {
        super.setTheme(customTheme);
    }/*from   w  w w .j a  v  a  2s  .co  m*/

    setContentView(R.layout.activity_store);

    SectionsPagerAdapter pagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

    ActionBar mActionBar = getActionBar();
    if (mActionBar != null) {
        mActionBar.setDisplayHomeAsUpEnabled(true);
    }
}

From source file:org.leopub.mat.controller.InboxItemActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_inbox_item);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }/*w w w.  j ava  2  s .c o  m*/

    mUser = UserManager.getInstance().getCurrentUser();

    Intent intent = getIntent();
    int[] itemIdArray = intent.getIntArrayExtra(INBOX_ITEM_MSG_ID);
    mItemIdStack = new Stack<>();
    for (int itemId : itemIdArray) {
        mItemIdStack.push(itemId);
    }
    mItem = mUser.getInboxItemByMsgId(mItemIdStack.pop());
    updateView();
    mBroadcastReceiver = new MessageBroadcastReceiver();
    IntentFilter filter = new IntentFilter(Configure.BROADCAST_MESSAGE);
    LocalBroadcastManager.getInstance(MyApplication.getAppContext()).registerReceiver(mBroadcastReceiver,
            filter);
}

From source file:org.ounl.lifelonglearninghub.nfcecology.db.ViewGoalActivity.java

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

    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        sGoalId = extras.getString(Goal.KEY_NAME);
    }//from   w  w w. j  a  v a2 s.  co  m

    loadGoalValues();

    // Enable home button
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

}

From source file:com.iutiao.sdk.IUTiaoActivity.java

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

    //  ActionBar
    ActionBar ab = getActionBar();
    if (ab != null) {
        ab.setHomeButtonEnabled(true);/* w  w w .  j  av a 2 s.  c  o  m*/
        ab.setDisplayHomeAsUpEnabled(true);
    }

    setContentView(R.layout.com_iutiao_activity_layout);

    Intent intent = getIntent();

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentByTag(FRAGMENT_TAG);

    // attach fragment to activity
    if (fragment == null) {

        String token = RequestOptions.getInstance().getToken();

        if (IUTiaoDialogFragment.TAG.equals(intent.getAction())) {
            IUTiaoDialogFragment dialogFragment = IUTiaoDialogFragment.newInstance();
            dialogFragment.setRetainInstance(true);
            dialogFragment.show(fm, FRAGMENT_TAG);
            fragment = dialogFragment;
        } else {
            if (token != null) {
                String frag = intent.getStringExtra("fragment");
                if (frag != null) {
                    if (frag.equals("charge")) {
                        //                            fragment = ChargeFragment.newInstance(getIntent());
                        //FIXME: hard code here.
                        fragment = UPayPaymentFragment.newInstance();
                    }
                } else {
                    fragment = ProfileFragment.newInstance();
                }
            } else {
                fragment = LoginFragment.newInstance();
            }
            fragment.setRetainInstance(true);
            fm.beginTransaction().add(R.id.com_iutiao_fragment_container, fragment, FRAGMENT_TAG).commit();
        }
    }

    singleFragment = fragment;
}

From source file:com.jaspersoft.android.jaspermobile.activities.repository.LibraryActivity.java

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

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//www.  ja v  a2s  . c  om

    if (savedInstanceState == null) {
        // Reset all controls state
        pref.clear();

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

        resourcesController = ResourcesControllerFragment_.builder()
                .emptyMessage(R.string.r_browser_nothing_to_display).resourceTypes(filterOptions.getFilters())
                .sortOrder(sortOptions.getOrder()).recursiveLookup(true).build();
        transaction.add(resourcesController, ResourcesControllerFragment.TAG);

        searchControllerFragment = SearchControllerFragment_.builder().resourceTypes(filterOptions.getFilters())
                .build();
        transaction.add(searchControllerFragment, SearchControllerFragment.TAG);
        transaction.commit();
    } else {
        resourcesController = (ResourcesControllerFragment) getSupportFragmentManager()
                .findFragmentByTag(ResourcesControllerFragment.TAG);
        searchControllerFragment = (SearchControllerFragment) getSupportFragmentManager()
                .findFragmentByTag(SearchControllerFragment.TAG);
    }

    updateOptionsMenu();
}

From source file:name.gumartinm.weather.information.activity.SpecificActivity.java

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

    final ActionBar actionBar = this.getActionBar();

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setDisplayHomeAsUpEnabled(true);

}

From source file:org.sudowars.Controller.Local.Activity.Manual.java

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

    setContentView(R.layout.manual);//from  w ww  . jav  a2  s . c om

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

    mManualPagerAdapter = new ManualPagerAdapter(getSupportFragmentManager(), getResources());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mManualPagerAdapter);
}

From source file:in.ac.iitb.intulearn.DetailsActivity.java

/**
 * Initialise the fragments to be paged//w  w w. j  a v  a 2s  .c  o m
 */
private void initialisePaging() {

    // Set up the action bar.
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // Show the Up button in the action bar.
    actionBar.setDisplayHomeAsUpEnabled(true);

    // REF: http://android-er.blogspot.in/2012/06/create-actionbar-in-tab-navigation-mode.html
    actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_description)
            .setTabListener(new CustomTabListener(this, DescriptionFragment.class.getName())));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_experiment)
            .setTabListener(new CustomTabListener(this, ExperimentFragment.class.getName())));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_evaluate)
            .setTabListener(new CustomTabListener(this, EvaluateFragment.class.getName())));

}