Methods Summary |
---|
private void | dispatchInitParams()
onInitParams(mParams);
onParamsChanged();
|
public int | findItemPosition(android.view.MenuItem item)Finds the position for a given Item.
// Could create reverse mapping, but optimizations aren't important (yet :P)
for (int i = 0; i < mParams.numItems; i++) {
if (mItems[i] == item) return i;
}
return -1;
|
public android.view.View | getItemView(int menuType, int position)Gets the menu item view for a given position.
return getMenuAdapter(menuType).getView(position, null, null);
|
public android.view.Menu | getMenu()
return mMenu;
|
public com.android.internal.view.menu.MenuBuilder.MenuAdapter | getMenuAdapter(int menuType)
if (mMenuAdapters[menuType] == null) {
mMenuAdapters[menuType] = ((MenuBuilder) mMenu).getMenuAdapter(menuType);
}
return mMenuAdapters[menuType];
|
public android.view.View | getMenuView(int menuType)Gets a menu view. Call this after you're sure it has been shown,
otherwise it may not have the proper layout_* attributes set.
return ((MenuBuilder) mMenu).getMenuView(menuType, null);
|
protected android.view.MenuItem | onAddMenuItem(android.view.Menu menu, int itemPosition)Override this to add an item to the menu.
return null;
|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
dispatchInitParams();
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
// Safe to hold on to
mMenu = menu;
if (!mParams.shouldShowMenu) return false;
MenuItem item;
for (int i = 0; i < mParams.numItems; i++) {
if ((item = onAddMenuItem(menu, i)) == null) {
// Add a default item for this position if the subclasses
// haven't
CharSequence givenTitle = mParams.itemTitles.get(i);
item = menu.add(0, 0, 0, (givenTitle != null) ? givenTitle : ("Item " + i));
}
if (item != null) {
mItems[i] = item;
if (mParams.listenForClicks) {
item.setOnMenuItemClickListener(this);
}
}
}
return true;
|
protected void | onInitParams(com.android.frameworktest.menus.MenuScenario$Params params)Override this to set the parameters for the scenario. Call through to super first.
|
public boolean | onMenuItemClick(android.view.MenuItem item)
final int position = findItemPosition(item);
if (position < 0) return false;
mWasItemClicked[position] = true;
return true;
|
public void | onParamsChanged()
mItems = new MenuItem[mParams.numItems];
mWasItemClicked = new boolean[mParams.numItems];
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
// Safe to hold on to
mMenu = menu;
return mParams.shouldShowMenu;
|
public void | setParams(com.android.frameworktest.menus.MenuScenario$Params params)
mParams = params;
onParamsChanged();
|
public boolean | wasItemClicked(int position)
return mWasItemClicked[position];
|