當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。