【问题标题】:Is it possible to add menu items when popupScreen is opened in blackberry在黑莓中打开popupScreen时是否可以添加菜单项
【发布时间】:2012-04-04 21:28:13
【问题描述】:
public class xyz extends PopupScreen{
}

现在我想在此屏幕弹出时添加菜单项。我尝试像主屏幕一样添加菜单项,但它在弹出屏幕中不起作用。

【问题讨论】:

  • 当前 popupScreen 为 popup 时,是否要将 menuItems 添加到上一个屏幕?

标签: blackberry user-interface


【解决方案1】:

无法在弹屏上添加菜单,因为问题是例如:-

我有一个主屏幕调用作为示例屏幕,在示例屏幕上假设我有保存和取消菜单,现在我从主屏幕推送一个弹出屏幕。现在,如果我说我也想在弹出屏幕上保存和取消菜单,那么黑莓无法识别是哪个菜单,它是示例屏幕还是弹出屏幕。

所以,这就是黑莓不支持弹出屏幕菜单的原因。

【讨论】:

    【解决方案2】:

    按照您的要求尝试这个示例类:

    public class SimpleScreen extends MainScreen
    {
    Font font;
    private MenuItem saveItem;
    private ButtonField buttonField;
    public SimpleScreen() 
    {
        font=Font.getDefault().derive(Font.ITALIC|Font.BOLD, 20);
        createGUI();        
        this.setFont(font);
    }
    
    private void createGUI()
    {
        buttonField=new ButtonField("Click For Popup",Field.FIELD_HCENTER);
        buttonField.setChangeListener(new FieldChangeListener() 
        {
            public void fieldChanged(Field field, int context) 
            {
                UiApplication.getUiApplication().pushScreen(new ScreenPopup(SimpleScreen.this));
            }
        });
        add(buttonField);
    
    }
    
    public void addMenuItemToMenu()
    {
        if(saveItem==null)
        {
            saveItem=new MenuItem("Save",100,101) 
            {
                public void run() 
                {
                    Status.show("Clicked on Save Menu", 500);
                }
            };
            addMenuItem(saveItem);
        }
    }           
    }
    
    class ScreenPopup extends PopupScreen
    {
    private SimpleScreen simpleScreen;
    public ScreenPopup(SimpleScreen simpleScreen) 
    {
        super(new HorizontalFieldManager(),PopupScreen.DEFAULT_CLOSE);
        this.simpleScreen=simpleScreen;
        this.add(new LabelField("ADDING Menu By Clicking the Back Button"));
    }
    
    public boolean onClose() 
    {
        simpleScreen.addMenuItemToMenu();
        return super.onClose();
    }
    }
    

    【讨论】:

    • 感谢您的回答,但我通过扩展主屏幕制作了一个自定义对话框......................
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多