当前位置: 首页>>代码示例>>Java>>正文


Java Toolbar.getTitle方法代码示例

本文整理汇总了Java中android.support.v7.widget.Toolbar.getTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.getTitle方法的具体用法?Java Toolbar.getTitle怎么用?Java Toolbar.getTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.Toolbar的用法示例。


在下文中一共展示了Toolbar.getTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyFontToToolbar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
/**
 * Will forceably set text on the views then remove ones that didn't have copy.
 *
 * @param view toolbar view.
 */
private void applyFontToToolbar(final Toolbar view) {
    final CharSequence previousTitle = view.getTitle();
    final CharSequence previousSubtitle = view.getSubtitle();
    // The toolbar inflates both the title and the subtitle views lazily but luckily they do it
    // synchronously when you set a title and a subtitle programmatically.
    // So we set a title and a subtitle to something, then get the views, then revert.
    view.setTitle(" ");
    view.setSubtitle(" ");

    // Iterate through the children to run post inflation on them
    final int childCount = view.getChildCount();
    for (int i = 0; i < childCount; i++) {
        onViewCreated(view.getChildAt(i), view.getContext(), null);
    }
    // Remove views from view if they didn't have copy set.
    view.setTitle(previousTitle);
    view.setSubtitle(previousSubtitle);
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:24,代码来源:CalligraphyFactory.java

示例2: initPrevState

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private ToolbarState initPrevState(Toolbar toolbar) {
    ToolbarState prevState = new ToolbarState();
    if (toolbar.getBackground() != null) {
        prevState.toolbarColor = ((ColorDrawable) (toolbar.getBackground())).getColor();
    }
    Context context = toolbar.getContext();
    TypedValue typedValue = new TypedValue();
    TypedArray attr = context.obtainStyledAttributes(typedValue.data,
            new int[]{R.attr.colorPrimary, R.attr.colorPrimaryDark});
    if (attr != null) {
        if (prevState.toolbarColor > 0) {
            prevState.toolbarColor = attr.getColor(0, 0);
        }
        @StyleableRes int index = 1;
        prevState.statusBarColor = attr.getColor(index, prevState.toolbarColor);
        attr.recycle();
    }

    if (toolbar.getTitle() != null) {
        prevState.title = toolbar.getTitle().toString();
    }

    if (toolbar.getSubtitle() != null) {
        prevState.subTitle = toolbar.getSubtitle().toString();
    }

    prevState.title = prevState.title != null ? prevState.title : EMPTY;
    prevState.subTitle = prevState.subTitle != null ? prevState.subTitle : EMPTY;

    prevState.logo = toolbar.getLogo();
    prevState.navigationIcon = toolbar.getNavigationIcon();


    return prevState;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:36,代码来源:MultiMode.java


注:本文中的android.support.v7.widget.Toolbar.getTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。