FileDocCategorySizeDatePackage
OverflowMenuAdapter.javaAPI DocAndroid 5.1 API3179Thu Mar 12 22:22:44 GMT 2015com.android.layoutlib.bridge.bars

OverflowMenuAdapter

public class OverflowMenuAdapter extends android.widget.BaseAdapter
Provides an adapter for Overflow menu popup. This is very similar to {@code MenuPopupHelper.MenuAdapter}

Fields Summary
private final com.android.internal.view.menu.MenuBuilder
mMenu
private int
mExpandedIndex
private final android.content.Context
context
Constructors Summary
public OverflowMenuAdapter(com.android.internal.view.menu.MenuBuilder menu, android.content.Context context)


         
        mMenu = menu;
        findExpandedIndex();
        this.context = context;
    
Methods Summary
private voidfindExpandedIndex()

        final MenuItemImpl expandedItem = mMenu.getExpandedItem();
        if (expandedItem != null) {
            final ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
            final int count = items.size();
            for (int i = 0; i < count; i++) {
                final MenuItemImpl item = items.get(i);
                if (item == expandedItem) {
                    mExpandedIndex = i;
                    return;
                }
            }
        }
    
public intgetCount()

        ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
        if (mExpandedIndex < 0) {
            return items.size();
        }
        return items.size() - 1;
    
public com.android.internal.view.menu.MenuItemImplgetItem(int position)

        ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
        if (mExpandedIndex >= 0 && position >= mExpandedIndex) {
            position++;
        }
        return items.get(position);
    
public longgetItemId(int position)

        // Since a menu item's ID is optional, we'll use the position as an
        // ID for the item in the AdapterView
        return position;
    
public android.view.ViewgetView(int position, android.view.View convertView, android.view.ViewGroup parent)

        if (convertView == null) {
            LayoutInflater mInflater = LayoutInflater.from(context);
            convertView = mInflater.inflate(com.android.internal.R.layout.popup_menu_item_layout,
                    parent, false);
        }

        MenuView.ItemView itemView = (MenuView.ItemView) convertView;
        itemView.initialize(getItem(position), 0);
        return convertView;