黑莓手机开发开发tips: 给MainScreen加菜单Menu

如下代码中,实现makeMenu()方法给EclScreen窗口加菜单。

 

public class EclScreen extends MainScreen
{
   RichTextField textField;

   public EclScreen()
    {
        setTitle("Pushed Data Listener");
        LabelField label = new LabelField("Pushed Data:");
        add(label);

        textField = new RichTextField();
        add(textField);

     }

 

    /******************************************************************************************
     * makeMenu(Menu,int) - creates a custom menu to add user define fields
    ******************************************************************************************/
     protected void makeMenu(Menu menu, int instance)
     {

        MenuItem optionMenu = new MenuItem("Option", 100, 10) {
            public void run() {
                OptionScreen screen = new OptionScreen();
                UiApplication.getUiApplication().pushScreen(screen); //点击菜单Option将弹出新的窗口OptionScreen

            }
        };    
         menu.add(optionMenu);
     }
}

 

你可能感兴趣的:(user,Class,手机,黑莓,menu)