本文整理了Java中android.support.v7.widget.Toolbar.getMenu()
方法的一些代码示例,展示了Toolbar.getMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.getMenu()
方法的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
方法名:getMenu
暂无
代码示例来源:origin: yanzhenjie/NoHttp
@Override
Menu getMenu() {
return mActionBar == null ? null : mActionBar.getMenu();
}
代码示例来源:origin: yanzhenjie/NoHttp
@Override
Menu getMenu() {
return mActionBar == null ? null : mActionBar.getMenu();
}
代码示例来源:origin: rey5137/material
/**
* This function should be called in onPrepareOptionsMenu(Menu) of Activity that use
* Toolbar as ActionBar, or after inflating menu.
*/
public void onPrepareMenu(){
if(mGroupChanged || mMenuDataChanged){
mToolbar.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
Menu menu = mToolbar.getMenu();
for(int i = 0, count = menu.size(); i < count; i++){
MenuItem item = menu.getItem(i);
item.setVisible(item.getGroupId() == mCurrentGroup || item.getGroupId() == 0);
}
mMenuDataChanged = false;
}
}
代码示例来源:origin: square/spoon
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!getIntent().hasExtra(KEY_AMOUNT_CENTS)) {
throw new IllegalStateException("Missing amount extra");
}
amount = getIntent().getLongExtra(KEY_AMOUNT_CENTS, -1);
if (amount < 100) {
throw new IllegalArgumentException("Invalid amount: " + amount);
}
setContentView(R.layout.recipeint);
ButterKnife.bind(this);
toolbar.setTitle(getString(R.string.send_amount, Moneys.formatCents(amount)));
toolbar.inflateMenu(R.menu.recipient);
sendMenuItem = toolbar.getMenu().findItem(R.id.recipient_send);
sendMenuItem.setEnabled(false);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.recipient_send:
onSendClicked();
return true;
default:
throw new IllegalStateException("Unknown menu item: " + item);
}
}
});
}
代码示例来源:origin: seven332/EhViewer
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (mToolbar != null) {
if (mTempTitle != null) {
mToolbar.setTitle(mTempTitle);
mTempTitle = null;
}
int menuResId = getMenuResId();
if (menuResId != 0) {
mToolbar.inflateMenu(menuResId);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return ToolbarScene.this.onMenuItemClick(item);
}
});
onMenuCreated(mToolbar.getMenu());
}
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNavigationClick();
}
});
}
}
代码示例来源:origin: code-mc/material-icon-lib
.inflate(R.menu.menu_nocolor, toolbar1.getMenu());
.with(this)
.setDefaultColor(Color.BLUE)
.inflate(R.menu.menu_nocolor, toolbar1.getMenu());
代码示例来源:origin: rsiebert/TVHClient
@Override
public void onPrepareOptionsMenu(Menu menu) {
menuUtils.onPreparePopupSearchMenu(menu, isNetworkAvailable);
if (nestedToolbar.getMenu() == null) {
return;
}
menu = nestedToolbar.getMenu();
menu.findItem(R.id.menu_edit).setVisible(true);
menu.findItem(R.id.menu_record_remove).setVisible(true);
}
代码示例来源:origin: rsiebert/TVHClient
@Override
public void onPrepareOptionsMenu(Menu menu) {
menuUtils.onPreparePopupSearchMenu(menu, isNetworkAvailable);
if (nestedToolbar.getMenu() == null) {
return;
}
menu = nestedToolbar.getMenu();
menu.findItem(R.id.menu_edit).setVisible(true);
menu.findItem(R.id.menu_record_remove).setVisible(true);
}
代码示例来源:origin: icechen1/Notable
@Override
public void onResume(){
super.onResume();
if(!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("enable_history", true)){
mToolbar.getMenu().findItem(R.id.menu_history).setVisible(false);
} else {
mToolbar.getMenu().findItem(R.id.menu_history).setVisible(true);
}
}
代码示例来源:origin: andforce/iBeebo
@Override
public void run() {
toolbar.getMenu().clear();
toolbar.inflateMenu(menuRes);
sMenuItem = toolbar.getMenu().findItem(R.id.notify_menu);
}
}, 200);
代码示例来源:origin: kochka/WeightLogger
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.edit_measurement_actionbar, menu);
if (getIntent().getExtras() == null) {
Toolbar actionBar = (Toolbar) findViewById(R.id.actionbar);
actionBar.getMenu().findItem(R.id.item_delete).setVisible(false);
}
return true;
}
代码示例来源:origin: Cutta/MaterialTransitionAnimation
@Override
public void onBackPressed() {
toolbar.setNavigationIcon(null);
toolbar.getMenu().clear();
super.onBackPressed();
}
代码示例来源:origin: ywwynm/EverythingDone
private void updateUndoRedoActionButtonState() {
MenuItem undoItem = mActionbar.getMenu().findItem(R.id.act_undo);
if (undoItem == null) {
return;
}
undoItem.setEnabled(mActionList.canUndo());
MenuItem redoItem = mActionbar.getMenu().findItem(R.id.act_redo);
redoItem.setEnabled(mActionList.canRedo());
}
代码示例来源:origin: kochka/WeightLogger
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.graph_actionbar, menu);
Toolbar actionBar = (Toolbar) findViewById(R.id.actionbar);
actionBar.getMenu().getItem(0).setVisible(false);
return true;
}
代码示例来源:origin: andforce/iBeebo
@Override
public void run() {
toolbar.getMenu().clear();
toolbar.inflateMenu(menuRes);
}
}, 200);
代码示例来源:origin: Simon-Leeeeeeeee/SLWidget
/**
* 初始化Toolbar
*/
private void initToolbar() {
mToolbar = findViewById(R.id.base_toolbar);
if (mToolbar == null) return;
Menu menu = mToolbar.getMenu();
if (menu instanceof MenuBuilder) {
((MenuBuilder) menu).setOptionalIconsVisible(true);
}
}
代码示例来源:origin: ImangazalievM/Bubbble
private Toolbar initToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.app_name);
toolbar.inflateMenu(R.menu.main);
initOptionsMenu(toolbar.getMenu());
return toolbar;
}
代码示例来源:origin: Stay/PullRecycler
protected void setUpMenu(int menuId) {
if (toolbar != null) {
toolbar.getMenu().clear();
if (menuId > 0) {
toolbar.inflateMenu(menuId);
toolbar.setOnMenuItemClickListener(this);
}
}
}
代码示例来源:origin: vickychijwani/udacity-p1-p2-popular-movies
@Override
public void onColorUpdate(int color) {
mToolbar.setTitleTextColor(titleTextColor);
tintDrawable(mToolbar.getNavigationIcon(), titleTextColor);
tintMenuItems(mToolbar.getMenu(), titleTextColor);
}
});
代码示例来源:origin: rsiebert/TVHClient
@Override
public void onPrepareOptionsMenu(Menu menu) {
// Show or hide menus of the main toolbar
menuUtils.onPreparePopupSearchMenu(menu, isNetworkAvailable);
// Show or hide menus of the nested toolbar
menu = nestedToolbar.getMenu();
menuUtils.onPreparePopupMenu(menu,
(program != null ? program.getStart() : 0),
(program != null ? program.getStop() : 0),
recording, isNetworkAvailable);
}
内容来源于网络,如有侵权,请联系作者删除!