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