本文整理汇总了Java中android.support.design.internal.NavigationMenu类的典型用法代码示例。如果您正苦于以下问题:Java NavigationMenu类的具体用法?Java NavigationMenu怎么用?Java NavigationMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NavigationMenu类属于android.support.design.internal包,在下文中一共展示了NavigationMenu类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.design.internal.NavigationMenu; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu_items_sample);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final EditText inputView = (EditText) findViewById(R.id.puppy_name);
FabSpeedDial fabSpeedDial = ((FabSpeedDial) findViewById(R.id.fab_speed_dial));
fabSpeedDial.setMenuListener(new SimpleMenuListenerAdapter() {
@Override
public boolean onPrepareMenu(NavigationMenu navigationMenu) {
String input = inputView.getText().toString();
if (TextUtils.isEmpty(input)) {
Snackbar.make(findViewById(R.id.rootView), "Enter the name of your puppy",
Snackbar.LENGTH_SHORT).show();
return false;
}
setMenuItemTitle(navigationMenu, R.id.action_call, input);
setMenuItemTitle(navigationMenu, R.id.action_text, input);
setMenuItemTitle(navigationMenu, R.id.action_email, input);
setMenuItemVisibility(navigationMenu, R.id.action_call, R.id.menu_item_call_switch);
setMenuItemVisibility(navigationMenu, R.id.action_text, R.id.menu_item_text_switch);
setMenuItemVisibility(navigationMenu, R.id.action_email, R.id.menu_item_email_switch);
return true;
}
});
}
示例2: onPrepareMenu
import android.support.design.internal.NavigationMenu; //导入依赖的package包/类
@Override
public boolean onPrepareMenu(NavigationMenu navigationMenu) {
return true;
}
示例3: setMenuItemTitle
import android.support.design.internal.NavigationMenu; //导入依赖的package包/类
private void setMenuItemTitle(NavigationMenu menu, int menuItemId, CharSequence input) {
MenuItem menuItem = menu.findItem(menuItemId);
String oldMenuItemTitle = menuItem.getTitle().toString();
menuItem.setTitle(oldMenuItemTitle + " " + input);
}
示例4: setMenuItemVisibility
import android.support.design.internal.NavigationMenu; //导入依赖的package包/类
private void setMenuItemVisibility(NavigationMenu menu, int menuItemId, int switchItem) {
SwitchCompat switchView = (SwitchCompat) findViewById(switchItem);
menu.findItem(menuItemId).setVisible(switchView.isChecked());
}
示例5: onPrepareMenu
import android.support.design.internal.NavigationMenu; //导入依赖的package包/类
/**
* Called just before the menu items are about to become visible.
* Don't block as it's called on the main thread.
*
* @param navigationMenu The menu containing all menu items.
* @return You must return true for the menu to be displayed;
* if you return false it will not be shown.
*/
boolean onPrepareMenu(NavigationMenu navigationMenu);