Changes

Jump to: navigation, search
4.b. Add Image to the Menu
==== 4.b. Add Image to the Menu ====
4.b.1. Run the application. Click on the Add static fields for menu you should see the followingitem number:<br/>[[Image: BB_Menu.png | 300px]]<br/>
<source lang="java">
final static int MENU_ADD = 0;
final static int MENU_EDIT = 1;
final static int MENU_DELETE = 2;
final static int MENU_EMAIL = 3;
final static int MENU_MAP = 4;
</source>
 
4.b.2. Create an abstract class that extends MenuItem to be used for creating items with image:<br/>
<source lang="java">
/**
* Concrete implementation of abstract class MenuItem
* Creates a new MenuDemoMenuItem object
*/
ImageMenuItem(String title, int ordinal, int property, int numitemNum)
{
super(new StringProvider(title), ordinal, property);
// Create Image object from project resource
Bitmap bitmap;
switch(numitemNum)
{
case 0:
}
}
</soursesource> 4.b.3. Change the instantiation of menu items to use the new class created ''ImageMenuItem''. Pass the name of the menu item to the constructor:<br/><source lang="java"> // MenuItem addItem = new MenuItem(new StringProvider("Add Student"), 200, 2); // without image ImageMenuItem addItem = new ImageMenuItem("Add Student", 100, 1, MENU_ADD);</source>[[Image: BB_MenuImage.png | 300px]]<br/>
1
edit

Navigation menu