Source code
package android.support.v7.internal.view.menu;
import android.content.Context;
import android.support.v7.internal.view.menu.MenuBuilder.ItemInvoker;
import android.support.v7.internal.widget.TintTypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
public final class ExpandedMenuView extends ListView implements ItemInvoker, MenuView, OnItemClickListener {
private static final int[] TINT_ATTRS = new int[]{16842964, 16843049};
private int mAnimations;
private MenuBuilder mMenu;
public ExpandedMenuView(Context context, AttributeSet attrs) {
this(context, attrs, 16842868);
}
public ExpandedMenuView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs);
setOnItemClickListener(this);
TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, TINT_ATTRS, defStyleAttr, 0);
if (a.hasValue(0)) {
setBackgroundDrawable(a.getDrawable(0));
}
if (a.hasValue(1)) {
setDivider(a.getDrawable(1));
}
a.recycle();
}
public void initialize(MenuBuilder menu) {
this.mMenu = menu;
}
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
setChildrenDrawingCacheEnabled(false);
}
public boolean invokeItem(MenuItemImpl item) {
return this.mMenu.performItemAction(item, 0);
}
public void onItemClick(AdapterView parent, View v, int position, long id) {
invokeItem((MenuItemImpl) getAdapter().getItem(position));
}
public int getWindowAnimations() {
return this.mAnimations;
}
}