Search in sources :

Example 66 with MenuBuilder

use of com.android.internal.view.menu.MenuBuilder in project android_frameworks_base by DirtyUnicorns.

the class View method createContextMenu.

/**
     * Show the context menu for this view. It is not safe to hold on to the
     * menu after returning from this method.
     *
     * You should normally not overload this method. Overload
     * {@link #onCreateContextMenu(ContextMenu)} or define an
     * {@link OnCreateContextMenuListener} to add items to the context menu.
     *
     * @param menu The context menu to populate
     */
public void createContextMenu(ContextMenu menu) {
    ContextMenuInfo menuInfo = getContextMenuInfo();
    // Sets the current menu info so all items added to menu will have
    // my extra info set.
    ((MenuBuilder) menu).setCurrentMenuInfo(menuInfo);
    onCreateContextMenu(menu);
    ListenerInfo li = mListenerInfo;
    if (li != null && li.mOnCreateContextMenuListener != null) {
        li.mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo);
    }
    // Clear the extra information so subsequent items that aren't mine don't
    // have my extra info.
    ((MenuBuilder) menu).setCurrentMenuInfo(null);
    if (mParent != null) {
        mParent.createContextMenu(menu);
    }
}
Also used : ContextMenuInfo(android.view.ContextMenu.ContextMenuInfo) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Example 67 with MenuBuilder

use of com.android.internal.view.menu.MenuBuilder in project android_frameworks_base by DirtyUnicorns.

the class ActionMenuView method getMenu.

/**
     * Returns the Menu object that this ActionMenuView is currently presenting.
     *
     * <p>Applications should use this method to obtain the ActionMenuView's Menu object
     * and inflate or add content to it as necessary.</p>
     *
     * @return the Menu presented by this view
     */
public Menu getMenu() {
    if (mMenu == null) {
        final Context context = getContext();
        mMenu = new MenuBuilder(context);
        mMenu.setCallback(new MenuBuilderCallback());
        mPresenter = new ActionMenuPresenter(context);
        mPresenter.setReserveOverflow(true);
        mPresenter.setCallback(mActionMenuPresenterCallback != null ? mActionMenuPresenterCallback : new ActionMenuPresenterCallback());
        mMenu.addMenuPresenter(mPresenter, mPopupContext);
        mPresenter.setMenuView(this);
    }
    return mMenu;
}
Also used : Context(android.content.Context) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Aggregations

MenuBuilder (com.android.internal.view.menu.MenuBuilder)67 SubMenuBuilder (com.android.internal.view.menu.SubMenuBuilder)22 Context (android.content.Context)11 ActionMenuPresenter (android.widget.ActionMenuPresenter)10 ActionMenuView (android.widget.ActionMenuView)10 LayoutInflater (android.view.LayoutInflater)7 View (android.view.View)7 ViewGroup (android.view.ViewGroup)7 TextView (android.widget.TextView)7 TypedValue (android.util.TypedValue)6 ContextMenuInfo (android.view.ContextMenu.ContextMenuInfo)6 ContextThemeWrapper (android.view.ContextThemeWrapper)6 ContextMenuBuilder (com.android.internal.view.menu.ContextMenuBuilder)6 Theme (android.content.res.Resources.Theme)5 TypedArray (android.content.res.TypedArray)5 DisplayMetrics (android.util.DisplayMetrics)5 Menu (android.view.Menu)5 MenuInflater (android.view.MenuInflater)5 LayoutParams (android.view.ViewGroup.LayoutParams)5 ListView (android.widget.ListView)5