Example usage for android.app ActionBar setHomeButtonEnabled

List of usage examples for android.app ActionBar setHomeButtonEnabled

Introduction

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

Prototype

public void setHomeButtonEnabled(boolean enabled) 

Source Link

Document

Enable or disable the "home" button in the corner of the action bar.

Usage

From source file:eu.operando.operandoapp.settings.SettingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(MainContext.INSTANCE.getSettings().getThemeStyle().themeDeviceDefaultStyle());

    super.onCreate(savedInstanceState);

    getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingPreferenceFragment())
            .commit();/*  ww  w  . j a v a2  s . c  om*/

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

From source file:com.art2cat.dev.moonlightnote.controller.settings.SettingsSecondActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_security_second);
    android.app.ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }/*from w  w  w .  j av  a  2  s. c om*/

    int type = getIntent().getIntExtra(Constants.EXTRA_TYPE_FRAGMENT, 0);

    FragmentManager fragmentManager = getSupportFragmentManager();
    int id = R.id.activity_security;
    switch (type) {
    case Constants.FRAGMENT_POLICY:
        FragmentUtils.addFragment(fragmentManager, id, new PrivacyPolicyFragment().newInstance());
        break;
    case Constants.FRAGMENT_LICENSE:
        FragmentUtils.addFragment(fragmentManager, id, new LicenseFragment().newInstance());
        break;
    case Constants.FRAGMENT_ABOUT:
        FragmentUtils.addFragment(fragmentManager, id, new AboutAppFragment().newInstance());
        break;
    }
}

From source file:com.aqnote.app.wifianalyzer.settings.SettingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setCustomTheme();/*from w w w.  ja v  a2 s.  c om*/

    super.onCreate(savedInstanceState);

    getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingPreferenceFragment())
            .commit();

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

From source file:com.hybris.mobile.activity.UIComponentsActivity.java

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

    setContentView(R.layout.activity_ui_components);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    Fragment[] frags = { new UIComponents1Fragment(), new UIComponents2Fragment() };
    FragmentPagerAdapter adapter = new TabsAdapter(getFragmentManager(), frags);
    mViewPager.setAdapter(adapter);// w w  w .j a v a2  s  . co m
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getActionBar().setSelectedNavigationItem(position);
        }
    });

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    MyTabListener tabListener = new MyTabListener(mViewPager, actionBar);
    Tab tab = actionBar.newTab().setText(R.string.tab_ui_components1).setTabListener(tabListener);
    actionBar.addTab(tab);

    tab = actionBar.newTab().setText(R.string.tab_ui_components2).setTabListener(tabListener);
    actionBar.addTab(tab);
    actionBar.setSelectedNavigationItem(0);
}

From source file:net.cherryzhang.sekuhara.LoginAndRegistration.LoginAndRegistrationActivity.java

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

    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    Parse.initialize(this, "TsVbzF7jXzY1C0o86V2xxAxgSxvy4jmbyykOabPl",
            "VzamwWm4WswbDFxrxos2oSerQ2Av4RM6J5mNnNgr");

    final ActionBar actionBar = getActionBar();
    actionBar.hide();// www  .j  a  v  a2s  .  c o m
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

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

    ViewPager.SimpleOnPageChangeListener mPageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    };

    pageIndicator = (CirclePageIndicator) findViewById(R.id.CPI_pageIndicator);
    pageIndicator.setViewPager(mViewPager);
    pageIndicator.setOnPageChangeListener(mPageChangeListener);
    pageIndicator.setCurrentItem(0);

    //TODO: make circle page indicator look better
    final float density = getResources().getDisplayMetrics().density;
    pageIndicator.setRadius(6 * density);
    pageIndicator.setPageColor(0xFFFFCCFF);
    pageIndicator.setFillColor(0xFFFF6699);
    pageIndicator.setStrokeColor(0xFF000000);
    pageIndicator.setStrokeWidth(1);

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.prolificcoder.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override// w w w.  ja  v a 2s  .c  o  m
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.poloure.simplerss.FragmentNavigationDrawer.java

void setUp(DrawerLayout drawerLayout) {
    final FeedsActivity activity = (FeedsActivity) getActivity();

    // Set up the action bar.
    ActionBar actionBar = activity.getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    s_drawerToggle = new ActionBarDrawerToggle(getActivity(), drawerLayout, R.drawable.ic_drawer,
            R.string.drawer_open, R.string.drawer_close) {
        @Override//from  ww  w.  j  av  a  2 s  .c o m
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);

            activity.m_showMenuItems = 0.0F == slideOffset;
            activity.invalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);

            if (!m_userLearnedDrawer) {
                m_userLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).commit();
            }
        }
    };

    // Open the drawer if the user has never opened it manually before.
    if (!m_userLearnedDrawer) {
        drawerLayout.openDrawer(Gravity.START);
    }

    drawerLayout.post(new SyncPost());
    drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    drawerLayout.setDrawerListener(s_drawerToggle);
}

From source file:org.ounl.lifelonglearninghub.nfcecology.swipe.SwipeActivity.java

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

    // Create the adapter that will return a fragment for each of the three
    // primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

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

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener
    // for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//from w  w  w. j  av  a  2  s .co  m
        public void onPageSelected(int position) {
            // When swiping between different app sections, select
            // the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if
            // we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter.
        // Also specify this Activity object, which implements the
        // TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

}

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);
        ab.setDisplayHomeAsUpEnabled(true);
    }//from w  ww.  ja v  a  2 s.  com

    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:net.noviden.android.shoutout.NewPostScreen.java

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

    mNewPost = (EditText) findViewById(R.id.send_text_field);

    ActionBar mNewPostActionBar = getActionBar();
    mNewPostActionBar.setDisplayHomeAsUpEnabled(true);
    mNewPostActionBar.setHomeButtonEnabled(true);
}