本文整理汇总了Java中android.view.MenuItem.setOnActionExpandListener方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setOnActionExpandListener方法的具体用法?Java MenuItem.setOnActionExpandListener怎么用?Java MenuItem.setOnActionExpandListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setOnActionExpandListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import android.view.MenuItem; //导入方法依赖的package包/类
/**
* <p>Sets a ColorFilter and/or alpha on all the {@link MenuItem}s in the menu, including the
* OverflowMenuButton.</p>
* <p>
* <p>Call this method after inflating/creating your menu in
* {@link Activity#onCreateOptionsMenu(Menu)}.</p>
* <p>
* <p>Note: This is targeted for the native ActionBar/Toolbar, not AppCompat.</p>
*
* @param activity the activity to apply the menu tinting on.
*/
public void apply(final Activity activity) {
if (forceIcons) {
forceMenuIcons(menu);
}
for (int i = 0, size = menu.size(); i < size; i++) {
MenuItem item = menu.getItem(i);
colorMenuItem(item, menuItemIconColor, menuItemIconAlpha);
if (reApplyOnChange) {
View view = item.getActionView();
if (view != null) {
if (item instanceof MenuItemImpl) {
((MenuItemImpl) item).setSupportOnActionExpandListener(
new SupportActionExpandListener(this));
} else {
item.setOnActionExpandListener(new NativeActionExpandListener(this));
}
}
}
}
actionBarView = findActionBar(activity);
if (actionBarView == null) {
Log.w(TAG, "Could not find the ActionBar");
return;
}
// We must wait for the view to be created to set a color filter on the drawables.
actionBarView.post(new Runnable() {
@Override
public void run() {
for (int i = 0, size = menu.size(); i < size; i++) {
MenuItem menuItem = menu.getItem(i);
if (isInOverflow(menuItem)) {
colorMenuItem(menuItem, subMenuIconColor, subMenuIconAlpha);
}
if (menuItem.hasSubMenu()) {
SubMenu subMenu = menuItem.getSubMenu();
for (int j = 0; j < subMenu.size(); j++) {
colorMenuItem(subMenu.getItem(j), subMenuIconColor, subMenuIconAlpha);
}
}
}
if (menuItemIconColor != null || menuItemIconAlpha != null) {
overflowButton = findOverflowMenuButton(activity, actionBarView);
colorOverflowMenuItem(overflowButton);
}
}
});
}
示例2: setOnActionExpandListener
import android.view.MenuItem; //导入方法依赖的package包/类
public static MenuItem setOnActionExpandListener(MenuItem item, SupportActionExpandProxy listener) {
return item.setOnActionExpandListener(new OnActionExpandListenerWrapper(listener));
}