首页 > 解决方案 > 代号一返回上一表单命令错误

问题描述

我想访问我的应用程序的本机硬件后退按钮以转到以前的表单。听起来微不足道,但是当使用此处找到的方法时,我遇到了一系列问题:

Command back = new Command("Back") {
     public void actionPerformed(ActionEvent ev) {

       showBack();
    }
};

或者

Command back = new Command("Back") {
     public void actionPerformed(ActionEvent ev) {

       showPreviousForm();
    }
};

对于这两种方法,我都会收到一条错误消息:

The method showBack() is undefined for the type new Command(){}

或者

The method PreviousForm() is undefined for the type new Command(){}

方法有没有变化?有不同的方法吗?

提前感谢您的任何回复。

标签: javacodenameoneback

解决方案


showBack是一种方法,Form因此如果命令在子类中定义,这将起作用Form。否则,您将需要一个表单实例来调用它。

showPreviousForm是一个自定义方法,您需要定义以某种方式显示以前的表单。


推荐阅读