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


Java Toolbar.setTitle方法代码示例

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


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

示例1: onCreate

import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_toolbar);

    /* The Toolbar -  introduced in API level 21 -  is a generalization of the concept of
    * actiobar, and can be placed at any level of the view heirarchy.
    *
    * The Toolbar is more versatile and powerful.
    *
    * An Activity can designate a Toolbar as its action bar, by invoking  setActionBar with
    * the Toolbar instance is its argument, as the following example illustrates.
    *
    * Sanjay Mishra
    * Author : "Wearable Android ..." 2015/ WILEY
    *
    *
    * */

    toolbar = (Toolbar) findViewById ( R.id.toolbarActionbar) ;
    toolbar.setTitle( R.string.toolbar_title);
    toolbar.setLogo( R.mipmap.ic_launcher);


    setActionBar(toolbar);

    actionBar = getActionBar() ;


}
 
开发者ID:smitzey,项目名称:wearbooksource,代码行数:31,代码来源:ToolbarActivity.java

示例2: initToolbar

import android.widget.Toolbar; //导入方法依赖的package包/类
private void initToolbar(Category category) {
    mToolbar = (Toolbar) findViewById(R.id.toolbar_activity_quiz);
    mToolbar.setTitle(category.getName());
    mToolbar.setNavigationOnClickListener(mOnClickListener);
    if (mSavedStateIsPlaying) {
        // the toolbar should not have more elevation than the content while playing
        mToolbar.setElevation(0);
    }
}
 
开发者ID:pierrebrtr,项目名称:ToutStade,代码行数:10,代码来源:QuizActivity.java

示例3: setTitle

import android.widget.Toolbar; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@BindingAdapter("title")
public static void setTitle(Toolbar toolbar, String resource) {
	toolbar.setTitle(resource);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:DataBindingAdapter.java

示例4: onCreate

import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  if (BuildConfig.USE_FLAG_SECURE) {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
      WindowManager.LayoutParams.FLAG_SECURE);
  }

  setContentView(R.layout.main);
  popupAnchor=findViewById(R.id.popup_anchor);

  AutoCompleteTextView autocomplete=
    (AutoCompleteTextView)findViewById(R.id.autocomplete);

  autocomplete.setAdapter(new ArrayAdapter<>(this,
    android.R.layout.simple_dropdown_item_1line,
    ITEMS));

  Spinner spinner=(Spinner)findViewById(R.id.spinner);
  ArrayAdapter<String> adapter=
    new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
      ITEMS);

  adapter
    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);

  spinner=(Spinner)findViewById(R.id.spinner2);
  adapter=
    new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
      ITEMS);
  adapter
    .setDropDownViewResource(
      android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);

  final View contextMenu=findViewById(R.id.context_menu);

  registerForContextMenu(contextMenu);
  contextMenu.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      openContextMenu(contextMenu);
    }
  });

  if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
    Toolbar tb=(Toolbar)findViewById(R.id.toolbar);

    tb.setTitle("Toolbar");
    tb.inflateMenu(R.menu.common);
    tb.setOnMenuItemClickListener(new OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        return(onOptionsItemSelected(item));
      }
    });
  }
}
 
开发者ID:commonsguy,项目名称:cwac-security,代码行数:61,代码来源:MainActivity.java


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