當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionBar.DISPLAY_HOME_AS_UP屬性代碼示例

本文整理匯總了Java中com.actionbarsherlock.app.ActionBar.DISPLAY_HOME_AS_UP屬性的典型用法代碼示例。如果您正苦於以下問題:Java ActionBar.DISPLAY_HOME_AS_UP屬性的具體用法?Java ActionBar.DISPLAY_HOME_AS_UP怎麽用?Java ActionBar.DISPLAY_HOME_AS_UP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.actionbarsherlock.app.ActionBar的用法示例。


在下文中一共展示了ActionBar.DISPLAY_HOME_AS_UP屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

private void init(View decor) {
    mContext = decor.getContext();
    mActionView = (ActionBarView) decor.findViewById(R.id.abs__action_bar);
    mContextView = (ActionBarContextView) decor.findViewById(
            R.id.abs__action_context_bar);
    mContainerView = (ActionBarContainer) decor.findViewById(
            R.id.abs__action_bar_container);
    mSplitView = (ActionBarContainer) decor.findViewById(
            R.id.abs__split_action_bar);

    if (mActionView == null || mContextView == null || mContainerView == null) {
        throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
                "with a compatible window decor layout");
    }

    mActionView.setContextView(mContextView);
    mContextDisplayMode = mActionView.isSplitActionBar() ?
            CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;

    // Older apps get the home button interaction enabled by default.
    // Newer apps need to enable it explicitly.
    boolean homeButtonEnabled = mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH;

    // If the homeAsUp display option is set, always enable the home button.
    homeButtonEnabled |= (mActionView.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0;

    setHomeButtonEnabled(homeButtonEnabled);

    setHasEmbeddedTabs(getResources_getBoolean(mContext,
            R.bool.abs__action_bar_embed_tabs));
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:31,代碼來源:ActionBarImpl.java

示例2: setHomeButtonEnabled

public void setHomeButtonEnabled(boolean enable) {
    mHomeLayout.setEnabled(enable);
    mHomeLayout.setFocusable(enable);
    // Make sure the home button has an accurate content description for accessibility.
    if (!enable) {
        mHomeLayout.setContentDescription(null);
    } else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:14,代碼來源:ActionBarView.java

示例3: initTitle

private void initTitle() {
    if (mTitleLayout == null) {
        LayoutInflater inflater = LayoutInflater.from(getContext());
        mTitleLayout = (LinearLayout) inflater.inflate(R.layout.abs__action_bar_title_item,
                this, false);
        mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title);
        mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle);
        mTitleUpView = mTitleLayout.findViewById(R.id.abs__up);

        mTitleLayout.setOnClickListener(mUpClickListener);

        if (mTitleStyleRes != 0) {
            mTitleView.setTextAppearance(mContext, mTitleStyleRes);
        }
        if (mTitle != null) {
            mTitleView.setText(mTitle);
        }

        if (mSubtitleStyleRes != 0) {
            mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
        }
        if (mSubtitle != null) {
            mSubtitleView.setText(mSubtitle);
            mSubtitleView.setVisibility(VISIBLE);
        }

        final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
        final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0;
        mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
        mTitleLayout.setEnabled(homeAsUp && !showHome);
    }

    addView(mTitleLayout);
    if (mExpandedActionView != null ||
            (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
        // Don't show while in expanded mode or with empty text
        mTitleLayout.setVisibility(GONE);
    }
}
 
開發者ID:ivanovpv,項目名稱:darksms,代碼行數:39,代碼來源:ActionBarView.java

示例4: setDisplayOptions

public void setDisplayOptions(int options) {
    final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
    mDisplayOptions = options;

    if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
        final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
        final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
        mHomeLayout.setVisibility(vis);

        if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mHomeLayout.setUp(setUp);

            // Showing home as up implicitly enables interaction with it.
            // In honeycomb it was always enabled, so make this transition
            // a bit easier for developers in the common case.
            // (It would be silly to show it as up without responding to it.)
            if (setUp) {
                setHomeButtonEnabled(true);
            }
        }

        if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
            final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
            mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
            if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
                initTitle();
            } else {
                removeView(mTitleLayout);
            }
        }

        if (mTitleLayout != null && (flagsChanged &
                (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
            final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
            mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
            mTitleLayout.setEnabled(!showHome && homeAsUp);
        }

        if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
            if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                addView(mCustomNavView);
            } else {
                removeView(mCustomNavView);
            }
        }

        requestLayout();
    } else {
        invalidate();
    }

    // Make sure the home button has an accurate content description for accessibility.
    if (!mHomeLayout.isEnabled()) {
        mHomeLayout.setContentDescription(null);
    } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:66,代碼來源:ActionBarView.java


注:本文中的com.actionbarsherlock.app.ActionBar.DISPLAY_HOME_AS_UP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。