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.Menu | getMenu()
return mMenu;
|
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(android.view.menu.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(android.view.menu.MenuScenario$Params params)
mParams = params;
onParamsChanged();
|
public boolean | wasItemClicked(int position)
return mWasItemClicked[position];
|