Example usage for android.app ActionBar setDisplayShowCustomEnabled

List of usage examples for android.app ActionBar setDisplayShowCustomEnabled

Introduction

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

Prototype

public abstract void setDisplayShowCustomEnabled(boolean showCustom);

Source Link

Document

Set whether a custom view should be displayed, if set.

Usage

From source file:org.billthefarmer.tuner.MainActivity.java

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

    // Find the views, not all may be present
    spectrum = (Spectrum) findViewById(R.id.spectrum);
    display = (Display) findViewById(R.id.display);
    strobe = (Strobe) findViewById(R.id.strobe);
    status = (Status) findViewById(R.id.status);
    meter = (Meter) findViewById(R.id.meter);
    scope = (Scope) findViewById(R.id.scope);

    // Add custom view to action bar
    ActionBar actionBar = getActionBar();
    actionBar.setCustomView(R.layout.signal_view);
    actionBar.setDisplayShowCustomEnabled(true);

    signal = (SignalView) actionBar.getCustomView();

    // Create audio
    audio = new Audio();

    // Connect views to audio
    if (spectrum != null)
        spectrum.audio = audio;//from  ww w . ja  v  a2s. co  m

    if (display != null)
        display.audio = audio;

    if (strobe != null)
        strobe.audio = audio;

    if (status != null)
        status.audio = audio;

    if (signal != null)
        signal.audio = audio;

    if (meter != null)
        meter.audio = audio;

    if (scope != null)
        scope.audio = audio;

    // Set up the click listeners
    setClickListeners();
}

From source file:com.inc.playground.playground.MainActivity.java

public void setPlayGroundActionBar() {
    String userLoginId, userFullName, userEmail, userPhoto;
    Bitmap imageBitmap = null;//from  ww  w . j  a  v  a  2 s  .  co m
    GlobalVariables globalVariables;
    final ActionBar actionBar = getActionBar();

    final String MY_PREFS_NAME = "Login";
    SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
    globalVariables = ((GlobalVariables) this.getApplication());
    if (prefs.getString("userid", null) != null) {
        userLoginId = prefs.getString("userid", null);
        userFullName = prefs.getString("fullname", null);
        userEmail = prefs.getString("emilid", null);
        userPhoto = prefs.getString("picture", null);
        globalVariables.GetCurrentUser().setPhotoUrl(userPhoto);
        actionBar.setCustomView(R.layout.actionbar_custom_view_home);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);

        ImageView logo_image = (ImageView) findViewById(R.id.img_profile_action_bar);
        logo_image.setBackgroundResource(R.drawable.pg_logo2);
        TextView userName = (TextView) findViewById(R.id.email);
        userName.setText(userFullName.replace("%20", "  "));
        ImageView img_profile = (ImageView) findViewById(R.id.profile_image);
        imageBitmap = globalVariables.GetUserPictureBitMap();
        if (imageBitmap == null) {
            Log.i(TAG, "downloading");
            try {
                imageBitmap = new DownloadImageBitmapTask().execute(userPhoto).get();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }

        } else {
            Log.i(TAG, "Image found");
        }
        img_profile.setImageBitmap(imageBitmap);

        ImageView notificationBtn = (ImageView) findViewById(R.id.notification_btn);
        notificationBtn.setVisibility(View.VISIBLE);
        notificationBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent iv = new Intent(MainActivity.this, NotificationsList.class);
                startActivity(iv);
                finish();
            }
        });
        TextView notificationNumber = (TextView) findViewById(R.id.notification__numberTxt);
        if (globalVariables.GetNotifications() != null && globalVariables.GetNotifications().size() != 0) {
            notificationNumber.setText(Integer.toString(globalVariables.GetNotifications().size()));
            notificationNumber.setVisibility(View.VISIBLE);
        } else {
            notificationNumber.setVisibility(View.INVISIBLE);
        }

        TextView loginTxt = (TextView) findViewById(R.id.login_txt);
        ImageView loginImg = (ImageView) findViewById(R.id.login_img);
        globalVariables.SetUserPictureBitMap(imageBitmap); // Make the imageBitMap global to all activities to avoid downloading twice
        loginTxt.setText("Logout");
        loginImg.setImageResource(R.drawable.pg_action_lock_close);
        // Register to notifications
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);

    }
}

From source file:com.tweetlanes.android.core.view.ProfileActivity.java

void configureActionBarView() {

    if (mScreenName != null) {

        final ActionBar actionBar = getActionBar();
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle("@" + mScreenName);

        final LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        final int layout = R.layout.profile_title_thin;
        /*/*from w w  w. j a  v  a  2s .  co m*/
         * // TODO: This is messy, and likely won't work for large screen
         * devices. Need to come up with a better solution int layout; if
         * (getResources().getConfiguration().orientation ==
         * Configuration.ORIENTATION_LANDSCAPE) { layout=
         * R.layout.profile_title_thin; } else { layout =
         * R.layout.profile_title; }
         */

        final View abView = inflator.inflate(layout, null);
        final ImageView verified = (ImageView) abView.findViewById(R.id.verifiedImage);
        verified.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE);

        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(abView);
    }
}

From source file:vn.cybersoft.obs.android.activities.DummyActivity.java

public void setActionBar() {
    ActionBar mActionBar = getActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);

    LayoutInflater mInflater = LayoutInflater.from(this);
    View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);

    TextView tvAppName = (TextView) mCustomView.findViewById(R.id.tvAppName);
    tvAppName.setText("Droid Battery Booster");

    ImageButton ivSearch = (ImageButton) mCustomView.findViewById(R.id.ivSearch);
    ivSearch.setOnClickListener(new OnClickListener() {

        @Override//from   ww  w. j  a  va  2 s.c om
        public void onClick(View view) {
            // slide_me.toggleRightDrawer();
        }
    });

    ImageView ivdrawer = (ImageView) mCustomView.findViewById(R.id.ivdrawer);
    ivdrawer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            // slide_me.toggleLeftDrawer();
            if (flag) {
                mDrawerLayout.openDrawer(Gravity.LEFT);
                flag = false;
            } else {
                mDrawerLayout.closeDrawer(Gravity.LEFT);
                flag = true;
            }
        }
    });
    mActionBar.setCustomView(mCustomView);
    mActionBar.setDisplayShowCustomEnabled(true);
}

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

/**
 * Hides every tab and shows search UI for phone lookup.
 *///from   www . j  av a  2s .  c  o  m
private void enterSearchUi() {
    if (mSearchFragment == null) {
        // We add the search fragment dynamically in the first onLayoutChange() and
        // mSearchFragment is set sometime later when the fragment transaction is actually
        // executed, which means there's a window when users are able to hit the (physical)
        // search key but mSearchFragment is still null.
        // It's quite hard to handle this case right, so let's just ignore the search key
        // in this case.  Users can just hit it again and it will work this time.
        return;
    }
    if (mSearchView == null) {
        prepareSearchView();
    }

    final ActionBar actionBar = getActionBar();

    final Tab tab = actionBar.getSelectedTab();

    // User can search during the call, but we don't want to remember the status.
    if (tab != null && !DialpadFragment.phoneIsInUse()) {
        mLastManuallySelectedFragment = tab.getPosition();
    }

    mSearchView.setQuery(null, true);

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    updateFakeMenuButtonsVisibility(false);

    for (int i = 0; i < TAB_INDEX_COUNT; i++) {
        sendFragmentVisibilityChange(i, false /* not visible */ );
    }

    // Show the search fragment and hide everything else.
    mSearchFragment.setUserVisibleHint(true);
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.show(mSearchFragment);
    transaction.commitAllowingStateLoss();
    mViewPager.setVisibility(View.GONE);

    // We need to call this and onActionViewCollapsed() manually, since we are using a custom
    // layout instead of asking the search menu item to take care of SearchView.
    mSearchView.onActionViewExpanded();
    mInSearchUi = true;
}

From source file:com.tweetlanes.android.view.ProfileActivity.java

boolean configureActionBarView() {

    if (mScreenName != null) {

        ActionBar actionBar = getActionBar();
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);

        LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        int layout = R.layout.profile_title_thin;
        /*/*ww  w.j a  v a2s. co m*/
         * // TODO: This is messy, and likely won't work for large screen devices. Need to come up with a better solution
        int layout;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
           layout= R.layout.profile_title_thin;
        } else {
           layout = R.layout.profile_title;
        }*/

        View profileTitleView = inflator.inflate(layout, null);
        ((TextView) profileTitleView.findViewById(R.id.screenname)).setText("@" + mScreenName);

        TextView fullNameTextView = (TextView) profileTitleView.findViewById(R.id.fullname);
        if (fullNameTextView != null && mUser != null) {
            fullNameTextView.setText(mUser.getName());
        }

        ImageView verifiedImage = (ImageView) profileTitleView.findViewById(R.id.verifiedImage);
        verifiedImage.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE);

        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(profileTitleView);
    }

    return true;
}

From source file:com.shafiq.mytwittle.view.ProfileActivity.java

boolean configureActionBarView() {

    if (mScreenName != null) {

        ActionBar actionBar = getActionBar();
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);

        LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        int layout = R.layout.profile_title_thin;
        /*//  www  . j  a  v  a  2s.co m
         * // TODO: This is messy, and likely won't work for large screen
         * devices. Need to come up with a better solution int layout; if
         * (getResources().getConfiguration().orientation ==
         * Configuration.ORIENTATION_LANDSCAPE) { layout=
         * R.layout.profile_title_thin; } else { layout =
         * R.layout.profile_title; }
         */

        View profileTitleView = inflator.inflate(layout, null);
        ((TextView) profileTitleView.findViewById(R.id.screenname)).setText("@" + mScreenName);

        TextView fullNameTextView = (TextView) profileTitleView.findViewById(R.id.fullname);
        if (fullNameTextView != null && mUser != null) {
            fullNameTextView.setText(mUser.getName());
        }

        ImageView verifiedImage = (ImageView) profileTitleView.findViewById(R.id.verifiedImage);
        verifiedImage.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE);

        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(profileTitleView);
    }

    return true;
}

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

/**
 * Goes back to usual Phone UI with tags. Previously selected Tag and associated Fragment
 * should be automatically focused again.
 *//*w w w. j a v  a 2 s. c  om*/
private void exitSearchUi() {
    final ActionBar actionBar = getActionBar();

    // Hide the search fragment, if exists.
    if (mSearchFragment != null) {
        mSearchFragment.setUserVisibleHint(false);

        final FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.hide(mSearchFragment);
        transaction.commitAllowingStateLoss();
    }

    // We want to hide SearchView and show Tabs. Also focus on previously selected one.
    actionBar.setDisplayShowCustomEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    for (int i = 0; i < TAB_INDEX_COUNT; i++) {
        sendFragmentVisibilityChange(i, i == mViewPager.getCurrentItem());
    }

    // Before exiting the search screen, reset swipe state.
    mDuringSwipe = false;
    mUserTabClick = false;

    mViewPager.setVisibility(View.VISIBLE);

    hideInputMethod(getCurrentFocus());

    // Request to update option menu.
    invalidateOptionsMenu();

    // See comments in onActionViewExpanded()
    mSearchView.onActionViewCollapsed();
    mInSearchUi = false;
}

From source file:com.notriddle.budget.EnvelopesActivity.java

private void configureFragment(Fragment frag) {
    ActionBar ab = getActionBar();
    if (frag instanceof TitleFragment) {
        TitleFragment tFrag = (TitleFragment) frag;
        setTitle(tFrag.getTitle());// w w w  .  java 2s  . c  o  m
        ab.setTitle(getTitle());
        boolean isTopLevel = false;
        for (int i = 0; i != mNavAdapter.getCount(); ++i) {
            if (mNavAdapter.getItem(i) == frag.getClass()) {
                mNavDrawer.setItemChecked(i, true);
                isTopLevel = true;
                break;
            } else {
                mNavDrawer.setItemChecked(i, false);
            }
        }
        mNavToggle.setDrawerIndicatorEnabled(isTopLevel);
    } else {
        throw new Error("Top-level fragment must be a TitleFragment");
    }
    if (frag instanceof DialogFragment) {
        DialogFragment dFrag = (DialogFragment) frag;
        dFrag.setShowsDialog(false);
    }
    if (frag instanceof ColorFragment) {
        ColorFragment cFrag = (ColorFragment) frag;
        onColorChange(cFrag.getColor());
    } else {
        onColorChange(0);
    }
    if (frag instanceof CustomActionBarFragment) {
        CustomActionBarFragment cFrag = (CustomActionBarFragment) frag;
        mCustomActionBarView = cFrag.onCreateActionBarView(getLayoutInflater());
        ab.setCustomView(mCustomActionBarView);
        ab.setDisplayShowTitleEnabled(false);
        ab.setDisplayShowCustomEnabled(true);
    } else {
        mCustomActionBarView = null;
        ab.setDisplayShowTitleEnabled(true);
        ab.setDisplayShowCustomEnabled(false);
        ab.setCustomView(null);
    }
}

From source file:org.opendatakit.survey.activities.MainMenuActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    PropertiesSingleton props = CommonToolProperties.get(this, getAppName());

    int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM;
    MenuItem item;/*from   ww  w. j  ava2 s.co  m*/
    if (currentFragment != ScreenList.WEBKIT) {
        ActionBar actionBar = getActionBar();
        actionBar.setCustomView(R.layout.action_bar);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.show();

        item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, R.string.sync);
        item.setIcon(R.drawable.ic_cached_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, R.string.about);
        item.setIcon(R.drawable.ic_info_outline_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    } else {
        ActionBar actionBar = getActionBar();
        actionBar.hide();
    }

    return true;
}