CodeNameOne动态创建的表单,如何“返回" [英] CodeNameOne Dynamically created Form, how to "Back"
本文介绍了CodeNameOne动态创建的表单,如何“返回"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在按钮的actionListener中,我们想动态创建一个Form.
In an actionListener for a button we would like to create a Form on the fly.
例如类似
Button b = new Button("Clickme");
b.setActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Form f = new Form();
Container c = new Container();
...
f.addComponent(c);
f.show();
}
});
哪个可以正常工作.....但是后退"按钮不起作用
Which works fine..... but "back" button will not work
有人知道在actionListener中实现动态表单或通过Action Listener跳转到预定义表单的正确方法吗?
Does anyone know the correct way of implementing a dynamic form in an actionListener, or jumping to a predefined form through and action Listener?
谢谢
詹姆斯
推荐答案
您需要创建一个back命令并将其与以下形式相关联:
You need to create a back command and associate it with the form:
Command back = new Command("Back") {
public void actionPerformed(ActionEvent ev) {
// notice that when showing a previous form it is best to use showBack() so the
// transition runs in reverse
showPreviousForm();
}
};
f.setBackCommand(back);
您可以在完全手工编码的厨房水槽演示中看到这一点.
You can see this in the kitchen sink demo which is entirely hand coded.
这篇关于CodeNameOne动态创建的表单,如何“返回"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文