java.lang.Object | |
↳ | com.neomades.ui.menu.Menu |
The Menu of the native platform.
This class doesn't need to be instantiated. Each menu belongs to a Screen,
which you can retrieve by overriding the
Screen.onMenuCreate(Menu)
method.
The following code explains how to add a menu in a screen by overriding
onMenuCreate(Menu)
:
public MyScreen extends Screen { protected void onMenuCreate(Menu menu) { menu.addItem(new MenuItem("Item 1")); } }
Menu can be added in complex screens like TabScreen
,
SplitScreen
or SlideScreen
and in their child screens inside.
The menu in composed screens (parent screen) will be shared between all the
child screens which composed the parent screen. If a child screen has its own
menu, it will be combined with the parent screen menu. The first items in the
menu will be the menu items in the parent screen.
MenuItem
can be added in the action bar using
setAsLeftAction()
and setAsRightAction()
.
Items will be placed to the left or to the right of the title in the bar.
Only one item can be set to the left of the title.
If there are several items set as left, only the first will be set
to the left, the others will be set to the right. The left action bar
button item is by default the back button. If it is replaced by an other
menu entry, be sure to implement an other way to exit the screen.
Contextual menu or action bar
In Android, the default menu is an Options Menu associated with the
menu button. It is opened by clicking on the menu button. By default,
MenuItem
will be added in this menu.
If the action bar is activated in the application (done by using
setActionBarEnabled(boolean)
in the application main
class), MenuItem
can be added in the action bar. Use
setAsLeftAction()
and setAsRightAction()
to
place items to the right or to the left of the title in the action bar.
Tool bar or action bar
In iOS platform, the default menu is shown as an UIToolbar. This tool bar will occupy around 40dp at the bottom of the screen and will be displayed only if the menu contains simple menu items.
Otherwise, MenuItem
can be added in the action bar using
setAsLeftAction()
and setAsRightAction()
.
Items will be placed to the left or to the right of the title in the bar.
Note: To provide the right image sizes for each platform, see
MenuItem
documentation.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | STYLE_BLACK | iOS UIToolBar Style Black | |||||||||
int | STYLE_DEFAULT | iOS UIToolBar Style Default |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
addItem(MenuItem item)
Adds an item to the menu.
| ||||||||||
void |
addSeparator()
Adds a separator in the menu.
| ||||||||||
void |
addSubMenu(SubMenu menu)
Adds an item with a sub-menu.
| ||||||||||
void |
clear()
Remove all the items from the menu
| ||||||||||
boolean |
isEmpty()
Checks if the menu is empty, there are no items in it.
| ||||||||||
boolean |
isVisible()
Checks whether the menu is visible.
| ||||||||||
void |
setStyle(int style)
Sets the iOS Menu UIToolBar style (bar at the bottom of the screen).
| ||||||||||
void |
setTranslucent(boolean translucent)
Sets the iOS Menu UIToolBar translucent or not (bar at the bottom of the
screen).
| ||||||||||
void |
setVisible(boolean visible)
Shows or hides the menu.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
iOS UIToolBar Style Black
iOS UIToolBar Style Default
Adds a separator in the menu.
For iOS: it adds a space between two items in the menu in the tool bar at the
bottom of the screen. Note that separators are always added in the tool bar.
They cannot be added between MenuItem
in the action bar.
For Android, this method does nothing.
Remove all the items from the menu
Checks if the menu is empty, there are no items in it.
Checks whether the menu is visible.
Sets the iOS Menu UIToolBar style (bar at the bottom of the screen).
STYLE_DEFAULT
for the classical blue theme, STYLE_BLACK
for
the iOS black theme.
In Android, this method has no effect.
style | the iOS Style |
---|
Sets the iOS Menu UIToolBar translucent or not (bar at the bottom of the screen).
In Android, this method has no effect.
translucent | true if the bar must be translucent |
---|
Shows or hides the menu.
In iOS, this method has no effect.
visible | true to set the menu visible. |
---|