Example usage for android.app ActionBar DISPLAY_SHOW_CUSTOM

List of usage examples for android.app ActionBar DISPLAY_SHOW_CUSTOM

Introduction

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

Prototype

int DISPLAY_SHOW_CUSTOM

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

Click Source Link

Document

Show the custom view if one has been set.

Usage

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

public ToolbarWidgetWrapper(Toolbar toolbar, boolean style, int defaultNavigationContentDescription,
        int defaultNavigationIcon) {
    mToolbar = toolbar;/*from  w w w  . j a v a 2s  . c o m*/
    mTitle = toolbar.getTitle();
    mSubtitle = toolbar.getSubtitle();
    mTitleSet = mTitle != null;
    mNavIcon = toolbar.getNavigationIcon();
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null,
            R.styleable.ActionBar, R.attr.actionBarStyle, 0);
    mDefaultNavigationIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
    if (style) {
        final CharSequence title = a.getText(R.styleable.ActionBar_title);
        if (!TextUtils.isEmpty(title)) {
            setTitle(title);
        }

        final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
        if (!TextUtils.isEmpty(subtitle)) {
            setSubtitle(subtitle);
        }

        final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
        if (logo != null) {
            setLogo(logo);
        }

        final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
        if (icon != null) {
            setIcon(icon);
        }
        if (mNavIcon == null && mDefaultNavigationIcon != null) {
            setNavigationIcon(mDefaultNavigationIcon);
        }
        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));

        final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
        if (customNavId != 0) {
            setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false));
            setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
        }

        final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
        if (height > 0) {
            final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
            lp.height = height;
            mToolbar.setLayoutParams(lp);
        }

        final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
        final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
        if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
            mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0));
        }

        final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        if (titleTextStyle != 0) {
            mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
        }

        final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        if (subtitleTextStyle != 0) {
            mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
        }

        final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0);
        if (popupTheme != 0) {
            mToolbar.setPopupTheme(popupTheme);
        }
    } else {
        mDisplayOpts = detectDisplayOptions();
    }
    a.recycle();

    mDrawableManager = AppCompatDrawableManager.get();

    setDefaultNavigationContentDescription(defaultNavigationContentDescription);
    mHomeDescription = mToolbar.getNavigationContentDescription();

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0,
                mTitle);

        @Override
        public void onClick(View v) {
            if (mWindowCallback != null && mMenuPrepared) {
                mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem);
            }
        }
    });
}

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

public ToolbarWidgetWrapper(Toolbar toolbar, boolean style, int defaultNavigationContentDescription,
        int defaultNavigationIcon) {
    mToolbar = toolbar;/*  w  w w  .  j a  va  2s  .c o  m*/
    mTitle = toolbar.getTitle();
    mSubtitle = toolbar.getSubtitle();
    mTitleSet = mTitle != null;
    mNavIcon = toolbar.getNavigationIcon();

    if (style) {
        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null,
                R.styleable.ActionBar, R.attr.actionBarStyle_ox, 0);

        final CharSequence title = a.getText(R.styleable.ActionBar_title);
        if (!TextUtils.isEmpty(title)) {
            setTitle(title);
        }

        final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
        if (!TextUtils.isEmpty(subtitle)) {
            setSubtitle(subtitle);
        }

        final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
        if (logo != null) {
            setLogo(logo);
        }

        final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
        if (mNavIcon == null && icon != null) {
            setIcon(icon);
        }

        final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator_ox);
        if (navIcon != null) {
            setNavigationIcon(navIcon);
        }

        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));

        final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
        if (customNavId != 0) {
            setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false));
            setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
        }

        final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
        if (height > 0) {
            final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
            lp.height = height;
            mToolbar.setLayoutParams(lp);
        }

        final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
        final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
        if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
            mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0));
        }

        final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        if (titleTextStyle != 0) {
            mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
        }

        final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        if (subtitleTextStyle != 0) {
            mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
        }

        final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0);
        if (popupTheme != 0) {
            mToolbar.setPopupTheme(popupTheme);
        }

        a.recycle();
    } else {
        mDisplayOpts = detectDisplayOptions();
    }

    mDrawableManager = AppCompatDrawableManager.get();

    setDefaultNavigationContentDescription(defaultNavigationContentDescription);
    mHomeDescription = mToolbar.getNavigationContentDescription();

    setDefaultNavigationIcon(mDrawableManager.getDrawable(getContext(), defaultNavigationIcon));

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0,
                mTitle);

        @Override
        public void onClick(View v) {
            if (mWindowCallback != null && mMenuPrepared) {
                mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem);
            }
        }
    });
}

From source file:se.eliga.aves.birddetail.BirdDetailsTabActivity.java

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

    final String latinSpecies = getIntent().getExtras().getString(BirdListFragment.LATIN_SPECIES);
    final String englishSpecies = getIntent().getExtras().getString(BirdListFragment.ENGLISH_SPECIES);
    final String swedishFamily = getIntent().getExtras().getString(BirdListFragment.SWEDISH_FAMILY);

    Bundle bundle = new Bundle(1);
    bundle.putString(BirdSpeciesWebFragment.ENGLISH_SPECIES, englishSpecies);
    bundle.putString(BirdSpeciesXenoCantoPlayerFragment.LATIN_SPECIES, latinSpecies);

    tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    tabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);

    tabHost.addTab(/*from  w  w w.j  av a  2  s. co  m*/
            tabHost.newTabSpec("Wikipedia").setIndicator(getText(R.string.tab_wikipedia),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesWebFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Flickr").setIndicator(getText(R.string.tab_photos),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFlickrGalleryFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("xeno-canto").setIndicator(getText(R.string.tab_sounds),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesXenoCantoPlayerFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Statistik").setIndicator(getText(R.string.tab_facts),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFactsFragment.class, bundle);
    tabHost.addTab(tabHost.newTabSpec("Karta").setIndicator(getText(R.string.tab_map),
            getResources().getDrawable(android.R.drawable.star_on)), MapFragment.class, bundle);

    TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    LinearLayout linearLayout = (LinearLayout) tabWidget.getParent();
    HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
    horizontalScrollView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    linearLayout.addView(horizontalScrollView, 0);
    linearLayout.removeView(tabWidget);
    horizontalScrollView.addView(tabWidget);
    horizontalScrollView.setHorizontalScrollBarEnabled(false);

    BirdListSpinnerAdapter birdListSpinnerAdapter = createAdapter();
    birdListSpinnerAdapter.setFilterFamily(swedishFamily);
    birdListSpinnerAdapter.initialize(getSharedPreferences(Constants.BIRD_APP_SETTINGS, Context.MODE_PRIVATE));
    if (BirdListAdapter.SortOption.PHYLOGENETIC.equals(birdListSpinnerAdapter.getSortOption())) {
        birdListSpinnerAdapter.setSortOption(BirdListAdapter.SortOption.SWEDISH);
    }

    birdListSpinnerAdapter.refresh();
    birdListSpinnerAdapter.notifyDataSetChanged();

    Spinner spinner = new Spinner(this);
    spinner.setId(R.id.birdspecies_spinner);
    spinner.setAdapter(birdListSpinnerAdapter);
    spinner.setGravity(Gravity.FILL_HORIZONTAL);

    spinner.setSelection(birdListSpinnerAdapter.getPosition(new Bird(latinSpecies)));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            BirdSpeciesFragment fragment = (BirdSpeciesFragment) getSupportFragmentManager()
                    .findFragmentByTag(tabHost.getCurrentTabTag());
            Spinner spinner = (Spinner) getActionBar().getCustomView().findViewById(R.id.birdspecies_spinner);
            fragment.loadBird((Bird) spinner.getSelectedItem());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    getActionBar().setCustomView(spinner);
    getActionBar().setDisplayOptions(
            ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);

}

From source file:com.alirezaafkar.toolbar.ToolbarWidgetWrapper.java

public ToolbarWidgetWrapper(RtlToolbar toolbar, boolean style, int defaultNavigationContentDescription,
        int defaultNavigationIcon) {
    mToolbar = toolbar;//from w  w  w .j a  va 2s .  co m
    mTitle = toolbar.getTitle();
    mSubtitle = toolbar.getSubtitle();
    mTitleSet = mTitle != null;
    mNavIcon = toolbar.getNavigationIcon();

    if (style) {
        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null,
                R.styleable.ActionBar, R.attr.actionBarStyle, 0);

        final CharSequence title = a.getText(R.styleable.ActionBar_title);
        if (!TextUtils.isEmpty(title)) {
            setTitle(title);
        }

        final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
        if (!TextUtils.isEmpty(subtitle)) {
            setSubtitle(subtitle);
        }

        final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
        if (logo != null) {
            setLogo(logo);
        }

        final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
        if (mNavIcon == null && icon != null) {
            setIcon(icon);
        }

        final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
        if (navIcon != null) {
            setNavigationIcon(navIcon);
        }

        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));

        final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
        if (customNavId != 0) {
            setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false));
            setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
        }

        final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
        if (height > 0) {
            final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
            lp.height = height;
            mToolbar.setLayoutParams(lp);
        }

        final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
        final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
        if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
            mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0));
        }

        final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        if (titleTextStyle != 0) {
            mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
        }

        final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        if (subtitleTextStyle != 0) {
            mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
        }

        final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0);
        if (popupTheme != 0) {
            mToolbar.setPopupTheme(popupTheme);
        }

        a.recycle();
    } else {
        mDisplayOpts = detectDisplayOptions();
    }

    mDrawableManager = AppCompatDrawableManager.get();

    setDefaultNavigationContentDescription(defaultNavigationContentDescription);
    mHomeDescription = mToolbar.getNavigationContentDescription();

    setDefaultNavigationIcon(mDrawableManager.getDrawable(getContext(), defaultNavigationIcon));

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0,
                mTitle);

        @Override
        public void onClick(View v) {
            if (mWindowCallback != null && mMenuPrepared) {
                mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem);
            }
        }
    });
}

From source file:com.docd.purefm.ui.activities.BrowserPagerActivity.java

private void initActionBar() {
    mActionBar = this.getActionBar();
    if (mActionBar == null) {
        throw new RuntimeException("BrowserPagerActivity should have an ActionBar");
    }//from w  w w  .  ja  v a  2s . co  m
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM
            | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP);

    //noinspection InflateParams
    final View custom = LayoutInflater.from(this).inflate(R.layout.activity_browser_actionbar, null);
    if (custom == null) {
        throw new RuntimeException("Inflated View is null");
    }
    mActionBar.setCustomView(custom);

    mBreadCrumbView = (BreadCrumbTextView) custom.findViewById(R.id.bread_crumb_view);
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_main);
    this.setTitle("School App");
    mTitle = mDrawerTitle = getTitle();//from  ww w  .  j a  va 2 s  .c o m

    settingsName = getResources().getStringArray(R.array.settings_array);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // 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));
    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: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  a2  s. c  o  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();/*  w w w.ja  v  a 2 s . c  o  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//  w  ww .  j av a2 s. c o 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:com.aegiswallet.actions.MainActivity.java

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

    application = (PayBitsApplication) getApplication();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    smsTxnsPrefs = application.getSharedPreferences(getString(R.string.sms_transaction_filename),
            Context.MODE_PRIVATE);
    //smsTxnsPrefs.edit().clear().commit();
    wallet = application.getWallet();//from  w  w  w . j  a  v  a2 s .c o  m
    application.initializeShamirSecretSharing(context);

    checkIfAppInitiated();

    setContentView(R.layout.activity_main);
    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getActionBar().setCustomView(R.layout.aegis_actionbar);

    openDrawerButton = (ImageButton) findViewById(R.id.action_bar_icon);
    openDrawerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mDrawerLayout != null) {
                if (mDrawerLayout.isDrawerOpen(Gravity.LEFT))
                    mDrawerLayout.closeDrawer(Gravity.LEFT);
                else
                    mDrawerLayout.openDrawer(Gravity.LEFT);
            }
        }
    });

    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    blockchainStatus = (TextView) findViewById(R.id.blockchain_status);
    blockchainStatus.setTypeface(BasicUtils.getCustomTypeFace(getBaseContext()));

    setupBlockchainBroadcastReceiver(blockchainStatus);

    GetCurrencyInfoTask currencyInfoTask = new GetCurrencyInfoTask(getApplicationContext());
    currencyInfoTask.execute();
    //currencyInfoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);

    watchedBalanceLinearLayout = (LinearLayout) findViewById(R.id.watched_balance_view);

    walletBalanceView = (TextView) findViewById(R.id.wallet_balance);
    walletBalanceView.setTypeface(BasicUtils.getCustomTypeFace(getBaseContext()));

    if (!prefs.contains(Constants.CURRENCY_PREF_KEY)) {
        prefs.edit().putString(Constants.CURRENCY_PREF_KEY, "USD").commit();
    }

    walletWatchAddressBalanceView = (TextView) findViewById(R.id.watch_only_balance);

    updateMainViews();
    determineSelectedAddress();
    application.startBlockchainService(false);
    handleButtons();

    recentTransactions = (ArrayList<Transaction>) wallet.getRecentTransactions(50, true);
    transactionListAdapter = new TransactionListAdapter(this, R.layout.transaction_detail_row,
            recentTransactions, wallet);

    transactionListView = (ListView) findViewById(R.id.transaction_list);
    if (recentTransactions == null || recentTransactions.size() == 0)
        transactionListView.setEmptyView(findViewById(R.id.transaction_empty_view_main));

    transactionListView.setAdapter(transactionListAdapter);

    handlePendingTransactions();

    initiateHandlers(walletBalanceView);
    application.addWalletListener(balanceHandler);

    checkWalletEncryptionStatus();
    this.registerReceiver(receiver, new IntentFilter(PeerBlockchainService.ACTION_BLOCKCHAIN_STATE));

    doDrawerSetup();

    String message = getIntent().getStringExtra("message");
    if (message != null) {
        Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        getIntent().removeExtra("message");
    }

    nfcEnabled = prefs.contains(Constants.SHAMIR_ENCRYPTED_KEY) ? false : true;
    checkBackupDone();
    doBackupReminder();

    isServiceBound = this.bindService(new Intent(this, PeerBlockchainService.class),
            blockchainServiceConnection, Context.BIND_AUTO_CREATE);

    HandleSMSResponsesTask handleSMSResponsesTask = new HandleSMSResponsesTask(this);
    //handleSMSResponsesTask.execute();
    handleSMSResponsesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);

    sendMessagesToWear();

}