本文整理匯總了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));
}
});
}
}