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:com.example.bijesh.mycollege10.MainActivity.java

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

    // 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();
    //action bar color
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar));
    //tab color//from   w ww. j  av  a  2  s  . c o m
    //   actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.bluewall));
    //tab background color
    //        actionBar.setStackedBackgroundDrawable(getResources().getDrawable(
    // R.drawable.greenwall));

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // 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
        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:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

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

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

    // Specify that the Home/Up button should not be enabled, since there is
    // no hierarchical
    // parent./*  w  ww . j  a  v  a  2s  .  c o  m*/
    actionBar.setHomeButtonEnabled(false);

    // 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
        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.univ.helsinki.app.MainActivity.java

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

    if (FeedResource.getInstance().getSharedPrefs().getBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH,
            false)) {//ww  w .  j  av a2s. c o  m

        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
        getActionBar().hide();

        hideTitle();
    }

    setContentView(R.layout.activity_main);

    splashLayout = (ViewGroup) findViewById(R.id.splashLayout);

    if (FeedResource.getInstance().getSharedPrefs().getBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH,
            false)) {
        // record the fact that the app has been started at least once
        FeedResource.getInstance().getSharedPrefs().edit()
                .putBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH, false).commit();

        final ViewGroup splashLayout = (ViewGroup) findViewById(R.id.splashLayout);

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                activateSplashScreen(splashLayout);
            }
        }, Constant.SPLASH_SCREEN_TIME_OUT);

    } else {
        splashLayout.setVisibility(View.GONE);
    }

    FeedResource.getInstance().inti(this);

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

    mSensorFeedAdapter = new SensorFeedAdapter(this);

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // 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
        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);
            switch (position) {
            case 0: {
                // on focus when first fragment
                //Toast.makeText(getApplicationContext(), "onPageSelected :" + position, Toast.LENGTH_SHORT).show();

                List<SensorFeed> mtempAllowedSensorFeedList = new ArrayList<SensorFeed>();
                // update the list over here.. to avoid empty shell
                for (SensorFeed sensor : FeedResource.getInstance().getSensorFeedList()) {

                    boolean isChecked = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
                            .getBoolean(sensor.getSensorKey(), false);

                    if (isChecked)
                        mtempAllowedSensorFeedList.add(sensor);
                }
                // update the list with new created list
                mSensorFeedAdapter.setFeedList(mtempAllowedSensorFeedList);

            }
                break;
            }// switch ends
        }
    });

    // 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.owo.android.mtPlease.MainActivity.java

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

    // Set up the action bar
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // setting for the sidedrawer
    // set the content view
    setBehindContentView(R.layout.drawer_search);
    getSlidingMenu().setFadeEnabled(true);
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setFadeDegree(0.90f);

    searchDrawerCloseButton = (ImageButton) findViewById(R.id.button_search_drawer_close);
    searchDrawerCloseButton.setOnClickListener(new OnClickListener() {

        @Override// w  ww.j a va2s  . c  o  m
        public void onClick(View v) {
            // TODO Auto-generated method stub
            getSlidingMenu().showContent();
        }

    });

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

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

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    //         
    mViewPager.setOffscreenPageLimit(3);

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.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 callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    locationSelectSpinner = (Spinner) findViewById(R.id.spinner_location);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.location_array,
            R.layout.spinner_text);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    locationSelectSpinner.setAdapter(adapter);

    datePickerButton = (Button) findViewById(R.id.button_datepicker);
    datePickerButton.setText(modifiedDate);
    datePickerButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            FragmentManager dialogManager = getFragmentManager();
            CalendarDialogFragment calendarDialogFragment = new CalendarDialogFragment();
            calendarDialogFragment.setParentCaller(CalendarDialogFragment.PARENT_IS_ACTIVITY);
            calendarDialogFragment.show(dialogManager, "calendar_dialog_popped");
        }

    });
    // Activity    emailAddress(SESSION_ID)  MyPageFragment
    // .

    //    
    searchButton = (ImageButton) findViewById(R.id.imageButton_search);
    searchButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            try {
                String region = locationSelectSpinner.getSelectedItem().toString();
                if (region.equals("")) {
                    region = "1";
                } else if (region.equals("")) {
                    region = "2";
                } else {
                    region = "3";
                }

                String people = ((EditText) findViewById(R.id.editText_numberPeople)).getText().toString();

                String[] tmp = (datePickerButton.getText().toString()).split(" ");
                String date = tmp[0].substring(0, 4) + "-" + tmp[1].split("")[0] + "-"
                        + tmp[2].split("")[0];

                String query = "?region=" + region + "&people=" + people + "&date=" + date + "&flag=1";
                sendInfoToFragment(people, 2);
                sendInfoToFragment(query, 0);

                getSlidingMenu().showContent();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                Toast.makeText(getApplicationContext(), "  ", Toast.LENGTH_SHORT);
                e.printStackTrace();
            }
        }

    });

}

From source file:org.jitsi.service.osgi.OSGiActivity.java

/**
 * Called when the activity is starting. Initializes the corresponding
 * call interface./* w  ww . j av  a2  s .  com*/
 *
 * @param savedInstanceState If the activity is being re-initialized after
 * previously being shut down then this Bundle contains the data it most
 * recently supplied in onSaveInstanceState(Bundle).
 * Note: Otherwise it is null.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void onCreate(Bundle savedInstanceState) {
    // Hooks the exception handler to the UI thread
    ExceptionHandler.checkAndAttachExceptionHandler();

    if (AndroidUtils.hasAPI(11)) {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {

            // Disable up arrow on home activity
            Class<?> homeActivity = JitsiApplication.getHomeScreenActivityClass();
            if (this.getClass().equals(homeActivity)) {
                actionBar.setDisplayHomeAsUpEnabled(false);

                if (AndroidUtils.hasAPI(14)) {
                    actionBar.setHomeButtonEnabled(false);
                }
            }

            ActionBarUtil.setTitle(this, getTitle());
        }
    }

    super.onCreate(savedInstanceState);

    ServiceConnection serviceConnection = new ServiceConnection() {
        public void onServiceConnected(ComponentName name, IBinder service) {
            if (this == OSGiActivity.this.serviceConnection)
                setService((BundleContextHolder) service);
        }

        public void onServiceDisconnected(ComponentName name) {
            if (this == OSGiActivity.this.serviceConnection)
                setService(null);
        }
    };

    this.serviceConnection = serviceConnection;

    boolean bindService = false;

    try {
        bindService = bindService(new Intent(this, OSGiService.class), serviceConnection, BIND_AUTO_CREATE);
    } finally {
        if (!bindService)
            this.serviceConnection = null;
    }

    // Registers exit action listener
    this.registerReceiver(exitListener, new IntentFilter(JitsiApplication.ACTION_EXIT));
}

From source file:it.durip_app.SensorPlot.java

/** Called when the activity is first created. */
@Override/*from w  w w .j a v  a 2 s .c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sensors);
    managerSensor = (SensorManager) getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
    textCharge = (TextView) findViewById(R.id.textvalueConsumption);
    // 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();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    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
        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);
        }
    });

    managerSensor = (SensorManager) this.getSystemService(SENSOR_SERVICE);
    List<Sensor> list = managerSensor.getSensorList(Sensor.TYPE_ALL);
    for (Sensor sensor : list) {
        System.out.println("NAME " + sensor.getName());
    }

    // For each of the sections in the app, add a tab to the action bar.
    for (int ii = 1; ii <= mAppSectionsPagerAdapter.getCount(); ii++) {
        // 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(ii)).setTabListener(this));

    }
    // Show the Up button in the action bar.        

    //        System.out.println("OnCreate \n");

}

From source file:com.ls.sip.CameraFragment.java

@Override
public void onHiddenChanged(boolean isHidden) {
    super.onHiddenChanged(isHidden);

    if (!isHidden) {
        ActionBar ab = getActivity().getActionBar();

        if (ab != null) {
            ab.setBackgroundDrawable(/*from  w w w  . ja  va  2  s  . c om*/
                    ContextCompat.getDrawable(getActivity(), R.drawable.cwac_cam2_action_bar_bg_transparent));
            ab.setTitle("");

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ab.setDisplayHomeAsUpEnabled(false);
            } else {
                ab.setDisplayShowHomeEnabled(false);
                ab.setHomeButtonEnabled(false);
            }
        }

        if (btnTakePicture != null) {
            btnTakePicture.setEnabled(true);
            btnSwitch.setEnabled(true);
        }
    }
}

From source file:com.moro.synapsemod.MainActivity.java

@SuppressWarnings("ConstantConditions")
private void continueCreate() {
    View v = LayoutInflater.from(this).inflate(R.layout.activity_main, null);

    mViewPager = (ViewPager) v.findViewById(R.id.mainPager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPagerPageChangeListener());
    mDrawerList = (ListView) v.findViewById(R.id.left_drawer);

    String[] section_titles = new String[Utils.configSections.size()];
    for (int i = 0; i < Utils.configSections.size(); i++)
        section_titles[i] = Utils.localise(((JSONObject) Utils.configSections.get(i)).get("name"));

    mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_item, section_titles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerList.setItemChecked(0, true);

    mDrawerLayout = (DrawerLayout) v.findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_action_drawer,
            R.string.drawer_open, R.string.drawer_close);
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    ActionBar actionBar = getActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    mDrawerToggle.syncState();/*from   www  .  ja  v  a 2s  .  c o m*/

    // Comprobamos "aplicar_cambios_auto" si esta activo cancelamos para que deje entrar al nuevo perfil
    SharedPreferences prefs = getSharedPreferences("moro_prefs", Context.MODE_PRIVATE);
    int auto = prefs.getInt("aplicar_cambios_auto", 0);

    // Si es 1 cancelamos para que entre el perfil y reiniciamos
    if (auto == 1) {
        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt("aplicar_cambios_auto", 2);
        editor.commit();
        // cancelamos
        ActionValueUpdater.cancelElements();
        // reiniciamos
        Utils.runCommand("/res/synapse/uci restart", false);
    }
    // Si es 2 aplicamos para que coja los voltajes
    else if (auto == 2) {
        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt("aplicar_cambios_auto", 0);
        editor.commit();
        // aplicamos
        ActionValueUpdater.applyElements();
    }
    // Si es 0 no hacemos nada
    else if (auto == 0)
        ActionValueUpdater.refreshButtons(true);

    for (TabSectionFragment f : fragments)
        f.onElementsMainStart();

    setContentView(v);
    actionBar.show();
    Utils.appStarted = true;

    setPaddingDimensions();
    L.i("Interface creation finished in " + (System.nanoTime() - startTime) + "ns");

    if (!BootService.getBootFlag() && !BootService.getBootFlagPending()) {
        new AlertDialog.Builder(this).setTitle(R.string.popup_failed_boot_title)
                .setMessage(R.string.popup_failed_boot_message).setCancelable(true)
                .setPositiveButton(R.string.popup_failed_boot_ack, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).show();
    }
}

From source file:com.bt.download.android.gui.activities.MainActivity.java

private void setupActionBar() {
    ActionBar bar = getActionBar();

    bar.setCustomView(R.layout.view_custom_actionbar);

    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayHomeAsUpEnabled(true);
    bar.setHomeButtonEnabled(true);
}

From source file:com.core.vmfiveadnetwork.MainActivity.java

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

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

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

    if (actionBar != null) {
        // Specify that the Home/Up button should not be enabled, since there is no hierarchical
        // parent.
        actionBar.setHomeButtonEnabled(false);

        // Specify that we will be displaying tabs in the action bar.
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }/*from  w  w w.  ja v  a 2  s. co m*/

    // 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
        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.

            if (actionBar != null)
                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.

        if (actionBar != null)
            actionBar.addTab(
                    actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    // check permissions for M, if some permission denied, it would shut down activity
    checkRequiredPermissions();

    // need to enable app scan in backend, and prompt this dialog to notice user
    //ADN.showAppScanDialog(this, "???App?");
}