Example usage for android.app ActionBar DISPLAY_SHOW_HOME

List of usage examples for android.app ActionBar DISPLAY_SHOW_HOME

Introduction

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

Prototype

int DISPLAY_SHOW_HOME

To view the source code for android.app ActionBar DISPLAY_SHOW_HOME.

Click Source Link

Document

Show 'home' elements in this action bar, leaving more space for other navigation elements.

Usage

From source file:com.embeddedlog.LightUpDroid.DeskClock.java

private void createTabs(int selectedIndex) {
    mActionBar = getActionBar();//  w  w  w. j a v a  2s .c  o m

    if (mActionBar != null) {
        mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME);
        mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        mAlarmTab = mActionBar.newTab();
        mAlarmTab.setIcon(R.drawable.alarm_tab);
        mAlarmTab.setContentDescription(R.string.menu_alarm);
        mTabsAdapter.addTab(mAlarmTab, AlarmClockFragment.class, ALARM_TAB_INDEX);

        mClockTab = mActionBar.newTab();
        mClockTab.setIcon(R.drawable.clock_tab);
        mClockTab.setContentDescription(R.string.menu_clock);
        mTabsAdapter.addTab(mClockTab, ClockFragment.class, CLOCK_TAB_INDEX);

        //mTimerTab = mActionBar.newTab();
        //mTimerTab.setIcon(R.drawable.timer_tab);
        //mTimerTab.setContentDescription(R.string.menu_timer);
        //mTabsAdapter.addTab(mTimerTab, TimerFragment.class, TIMER_TAB_INDEX);

        //mStopwatchTab = mActionBar.newTab();
        //mStopwatchTab.setIcon(R.drawable.stopwatch_tab);
        //mStopwatchTab.setContentDescription(R.string.menu_stopwatch);
        //mTabsAdapter.addTab(mStopwatchTab, StopwatchFragment.class,STOPWATCH_TAB_INDEX);

        mActionBar.setSelectedNavigationItem(selectedIndex);
        mTabsAdapter.notifySelectedPage(selectedIndex);

        forceTabsInActionBar(mActionBar);
    }
}

From source file:se.toxbee.sleepfighter.activity.EditGPSFilterAreaActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
    String name = this.printName();

    if (Build.VERSION.SDK_INT >= 11) {
        // add the custom view to the action bar.
        ActionBar actionBar = getActionBar();
        actionBar.setCustomView(R.layout.gpsfilter_area_actionbar);
        actionBar.setDisplayOptions(//from  w  w  w  .j a v a 2s  .co  m
                ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);

        View customView = actionBar.getCustomView();

        // Setup edit name component.
        EditText editNameView = (EditText) customView.findViewById(R.id.edit_gpsfilter_area_title_edit);
        editNameView.setText(name);
        editNameView.setOnEditorActionListener(new OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                area.setName(GPSFilterTextUtils.printName(getResources(), v.getText().toString()));
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                return false;
            }
        });
        editNameView.clearFocus();

        // Setup enabled switch.
        CompoundButton activatedSwitch = (CompoundButton) customView
                .findViewById(R.id.edit_gpsfilter_area_toggle);
        activatedSwitch.setChecked(this.area.isEnabled());
        activatedSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                area.setEnabled(isChecked);
            }
        });
    } else {
        this.setTitle(name);
    }
}

From source file:com.theoreticsinc.brucat.activities.DrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_main);
    this.setTitle("BruCat");
    mTitle = mDrawerTitle = getTitle();//from  w w w  . j  a  v a 2 s .  co  m

    settingsName = getResources().getStringArray(R.array.settings_array);
    subSettingsName = getResources().getStringArray(R.array.subsettings_array);
    settings_icon = getResources().obtainTypedArray(R.array.settings_icons);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    for (int i = 0; i < settingsName.length; i++) {
        mNavItems.add(new NavItem(settingsName[i], subSettingsName[i], settings_icon.getResourceId(i, 0)));
    }
    ;

    // set a custom shadow that overlays the items_list content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's listView view with items and click listener
    //mDrawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item, settingsName));
    DrawerListAdapter adapter = new DrawerListAdapter(this, mNavItems);
    mDrawerList.setAdapter(adapter);

    LayoutInflater inflator = this.getLayoutInflater();
    View headerView = inflator.inflate(R.layout.imagedrawer, null);
    //View headerView = LayoutInflater.from(this).inflate(R.layout.imagedrawer, mDrawerLayout);
    //((TextView) headerView.findViewById(R.id.textView1)).setText("Angelo");
    //mDrawerList.addHeaderView(headerView);

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    /*
            // enable ActionBar app icon to behave as action to toggle nav drawer
            ActionBar mActionBar = getActionBar();
            mActionBar.setDisplayShowHomeEnabled(true);
            mActionBar.setDisplayShowTitleEnabled(true);
            LayoutInflater mInflater = LayoutInflater.from(this);
            
            //getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
            //getActionBar().setDisplayUseLogoEnabled(false);
            //getActionBar().setDisplayShowCustomEnabled(true);
            //getActionBar().setCustomView(R.layout.custom_actionbar);
            //getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
            
            View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
            mActionBar.setCustomView(mCustomView);
            mActionBar.setDisplayShowCustomEnabled(true);
    */

    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
    getActionBar().setCustomView(R.layout.custom_actionbar);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    mDrawerLayout.openDrawer(Gravity.LEFT);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.blank, /* 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 */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }

}

From source file:com.android.contacts.activities.ContactDetailActivity.java

/** @} */

@Override//from w w  w.ja va2  s .  co m
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    LogUtils.i(TAG, "[onCreate][launch]start");
    ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet
    registerPHBReceiver();
    mIsActivitFinished = false;
    /** M: Bug Fix for ALPS00393950 @{ */
    boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this);
    if (!isUsingTwoPanes) {
        SetIndicatorUtils.getInstance().registerReceiver(this);
    }
    /** @} */
    if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        // This activity must not be shown. We have to select the contact in the
        // PeopleActivity instead ==> Create a forward intent and finish
        final Intent originalIntent = getIntent();
        Intent intent = new Intent();
        intent.setAction(originalIntent.getAction());
        intent.setDataAndType(originalIntent.getData(), originalIntent.getType());

        // If we are launched from the outside, we should create a new task, because the user
        // can freely navigate the app (this is different from phones, where only the UP button
        // kicks the user into the full app)
        if (shouldUpRecreateTask(intent)) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        } else {
            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }
        intent.setClass(this, PeopleActivity.class);
        startActivity(intent);
        LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity..");
        finish();
        return;
    }

    setContentView(R.layout.contact_detail_activity);

    mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(),
            null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener);

    // We want the UP affordance but no app icon.
    // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick.
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        ///@Modify for add Customer view{
        actionBar.setDisplayOptions(
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM,
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
                        | ActionBar.DISPLAY_SHOW_CUSTOM);
        ///@}
        actionBar.setTitle("");
    }

    Log.i(TAG, getIntent().getData().toString());
    /** M: New Feature xxx @{ */
    //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE
    if (getIntent() != null && getIntent().getData() != null) {
        mSimOrPhoneUri = getIntent().getData();
        Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri);
    } else {
        Log.e(TAG, "Get intent data error getIntent() = " + getIntent());
    }
    /// M: @ CT contacts detail history set listener{
    ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(),
            ContactPluginDefault.COMMD_FOR_OP09);
    /// @}
    LogUtils.i(TAG, "[onCreate][launch]end");
}

From source file:android.support.v7.widget.ToolbarWidgetWrapper.java

private int detectDisplayOptions() {
    int opts = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO;
    if (mToolbar.getNavigationIcon() != null) {
        opts |= ActionBar.DISPLAY_HOME_AS_UP;
        mDefaultNavigationIcon = mToolbar.getNavigationIcon();
    }/* ww w  . j  ava2 s. co m*/
    return opts;
}

From source file:com.dnielfe.manager.Browser.java

private void initActionBar() {
    mActionBar = this.getActionBar();
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM
            | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP);

    // set custom ActionBar layout
    final View mActionView = getLayoutInflater().inflate(R.layout.activity_browser_actionbar, null);
    mActionBar.setCustomView(mActionView);
    mActionBar.show();//from  w w w  .j  a  v  a  2s  . c  o  m
}

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

private int detectDisplayOptions() {
    int opts = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO;
    if (mToolbar.getNavigationIcon() != null) {
        opts |= ActionBar.DISPLAY_HOME_AS_UP;
    }/*from  w  ww .  j a  v a2  s.  c  om*/
    return opts;
}

From source file:com.dnielfe.manager.Browser.java

private void setupDrawer() {
    final TypedArray array = obtainStyledAttributes(new int[] { R.attr.themeId });
    final int themeId = array.getInteger(0, SimpleExplorer.THEME_ID_LIGHT);
    array.recycle();//from w w  w . j av a2s.c o m

    mDrawer = (LinearLayout) findViewById(R.id.left_drawer);

    // Set shadow of navigation drawer
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    int icon = themeId == SimpleExplorer.THEME_ID_LIGHT ? R.drawable.holo_light_ic_drawer
            : R.drawable.holo_dark_ic_drawer;

    // Add Navigation Drawer to ActionBar
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, icon, R.string.drawer_open,
            R.string.drawer_close) {

        @Override
        public void onDrawerOpened(View view) {
            super.onDrawerOpened(view);
            mActionBar.setDisplayOptions(
                    ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
            mActionBar.setTitle(R.string.app_name);
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            mActionBar.setDisplayOptions(
                    ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);
            invalidateOptionsMenu();
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

From source file:org.deviceconnect.android.deviceplugin.theta.fragment.ThetaGalleryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.theta_gallery, container, false);
    getActivity().getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME);
    ThetaDeviceApplication app = (ThetaDeviceApplication) getActivity().getApplication();
    mThumbnailCache = app.getCache();//from  w w  w  . j  a v  a 2s.c  om
    int color = R.color.action_bar_background;
    Drawable backgroundDrawable = getResources().getDrawable(color);
    getActivity().getActionBar().setBackgroundDrawable(backgroundDrawable);
    mRecconectLayout = (RelativeLayout) mRootView.findViewById(R.id.theta_reconnect_layout);
    mRootView.findViewById(R.id.theta_reconnect).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showSettingsActivity();
        }
    });
    mShootingButton = (Button) mRootView.findViewById(R.id.theta_shutter);
    mShootingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.putExtra(ThetaFeatureActivity.FEATURE_MODE, ThetaFeatureActivity.MODE_SHOOTING);
            intent.setClass(getActivity(), ThetaFeatureActivity.class);
            startActivity(intent);
        }
    });
    mStatusView = (TextView) mRootView.findViewById(R.id.theta_no_data);
    initListView(mRootView);
    initGalleryModeButtons(mRootView);
    return mRootView;
}

From source file:com.geotrackin.gpslogger.GpsMainActivity.java

public void SetUpActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(),
            R.array.gps_main_views, android.R.layout.simple_spinner_dropdown_item);

    actionBar.setListNavigationCallbacks(spinnerAdapter, this);

    //Reload the user's previously selected view f73
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    actionBar.setSelectedNavigationItem(prefs.getInt("dropdownview", 0));

    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("");
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
            | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.actionbar);

    ImageButton helpButton = (ImageButton) actionBar.getCustomView().findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override/*www.j  a v  a 2 s .  c  om*/
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}