當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.setOnActionExpandListener方法代碼示例

本文整理匯總了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);
            }
        }
    });
}
 
開發者ID:jamesddube,項目名稱:LaravelNewsApp,代碼行數:64,代碼來源:MenuTint.java

示例2: setOnActionExpandListener

import android.view.MenuItem; //導入方法依賴的package包/類
public static MenuItem setOnActionExpandListener(MenuItem item, SupportActionExpandProxy listener) {
    return item.setOnActionExpandListener(new OnActionExpandListenerWrapper(listener));
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:MenuItemCompatIcs.java


注:本文中的android.view.MenuItem.setOnActionExpandListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。