【发布时间】:2020-11-22 18:41:04
【问题描述】:
我有一个使用返回命令返回开始屏幕的 Android 应用程序。
开始屏幕有一个标签,里面有一个数字,我想在使用返回命令时更新它。
我可以用 back 命令中的代码找出一个解决方案,但我不知道我的方法是否是最好的,因为 ClassOne 会被加载两次。
这是我已有的代码:
public class ClassOne {
public ClassOne(ClassPojo classPojo) {
// I want to change the text of this label when calling the back command
labelOne.setText(classPojo.getStringTest());
formOne.show();
}
}
public class ClassTwo {
public ClassTwo(Form a , ClassPojo classPojo) {
Command back = new Command("A") {
@Override
public void actionPerformed(ActionEvent evt) {
// I am adding the new value for the label here inside the back command
classPojo.setStringTest("testing");
a.showBack();
new ClassOne(classPojo);
}
};
formTwo.setBackCommand(back);
}
【问题讨论】:
标签: codenameone back