Java 代号一:实现流体跟踪器的计算

Java 代号一:实现流体跟踪器的计算,java,codenameone,Java,Codenameone,我正在尝试实现一个循环加法计算。这应该获得当前数量(从数量文本字段)和保存的数量(要保存的总数量),并在“结果”标题下输出总结果 我尝试了以下代码,但它包含错误,并使用对话框输出结果(这不是我想要的) 因此,对于如何在我的代码中实现这一点,我将非常感谢您提供任何建议和指导。要在表格中显示它,您可以通过以下方式轻松使用GridLayout: Container ctrResultTable = new Container(new GridLayout(1,3)); //Define a new

我正在尝试实现一个循环加法计算。这应该获得当前数量(从数量文本字段)和保存的数量(要保存的总数量),并在“结果”标题下输出总结果

我尝试了以下代码,但它包含错误,并使用对话框输出结果(这不是我想要的)


因此,对于如何在我的代码中实现这一点,我将非常感谢您提供任何建议和指导。

要在表格中显示它,您可以通过以下方式轻松使用GridLayout:

Container ctrResultTable = new Container(new GridLayout(1,3)); 
//Define a new container associated to a gridlayout with 1 row and 1 column
ctrResult.addComponent(new Label(d.toString()));
ctrResult.addComponent(new Label(total.toString()));
ctrResult.addComponent(new Label((total/target*100).toString()));
//Because you use a value inside a function, addItem should be initialized as final
addItem.addComponent(ctrResult);

但是我不能为您的代码错误做任何事情,因为我在这里看不到完整的代码

要在表格中显示它,您可以通过以下方式轻松使用GridLayout:

Container ctrResultTable = new Container(new GridLayout(1,3)); 
//Define a new container associated to a gridlayout with 1 row and 1 column
ctrResult.addComponent(new Label(d.toString()));
ctrResult.addComponent(new Label(total.toString()));
ctrResult.addComponent(new Label((total/target*100).toString()));
//Because you use a value inside a function, addItem should be initialized as final
addItem.addComponent(ctrResult);
但是我不能为你的代码错误做任何事情,因为我在这里看不到完整的代码