首页 文章

从表单返回到特定选项卡 - codenameone

提问于
浏览
2

表格有标签

Tabs tabs = new Tabs(Component.BOTTOM);
tabs.addTab("Events", wrapContainerSingleTable);
tabs.addTab("Business Meetings", wrapContainerSingleTableMeeting);

Button addEventButton = new Button("Add Event ");
FontImage.setMaterialIcon(addEventButton, FontImage.MATERIAL_ADD);
wrapContainerSingleTable.add(FlowLayout.encloseRight(addEventButton));

addEventButton.addActionListener((e) -> {
    showForm("AddEvent", null);
});

Button addMeetingButton = new Button("Add Meeting ");
FontImage.setMaterialIcon(addMeetingButton, FontImage.MATERIAL_ADD);
wrapContainerSingleTableMeeting.add(FlowLayout.encloseRight(addMeetingButton));

addMeetingButton.addActionListener((e) -> {
    showForm("AddMeeting", null);
});

回到addEvent和addMeeting表单:

Command back = new Command("Back", backBtn) {
    @Override
    public void actionPerformed(ActionEvent evt) {
        showForm("MeetingsAndEvents", this);
    }

};
back.putClientProperty("uiid", "RoundTableBack");
f.setBackCommand(back);
t.addCommandToLeftBar(back);

我需要的是,当我从添加事件返回时,它应该转到事件选项卡,同样当我从添加 Session 选项卡返回时,它应该转到 Session 选项卡 . 我怎样才能做到这一点?

2 回答

  • 0

    尝试在actionPerformed()方法的Tabs组件上使用setSelectedIndex() .

  • 0

    将其添加到您的状态机:

    protected void storeComponentState(Component c, Hashtable destination) {
       super.storeComponentState(c, destination);
       if(c instanceof Tabs) {
            destination.put("TabSel" + c.getName(), ((Tabs)c).getSelectedIndex());
       }
    }
    
    protected void restoreComponentState(Component c, Hashtable destination) {
       super.restoreComponentState(c, destination);
       if(c instanceof Tabs) {
            Integer i = (Integer)destination.get("TabSel" + c.getName());
            if(i != null) {
               ((Tabs)c).setSelectedIndex(i.intValue());
            }
       }
    }
    

相关问题