本文整理汇总了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() ;
}
示例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);
}
}
示例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);
}
示例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));
}
});
}
}