如何从 codenameone OnOff 开关状态获取值。我在互联网上进行了搜索,但找不到示例。我想知道它何时打开或关闭。请帮忙。我已经尝试过这个和许多其他组合,但我还没有找到方法。我还通读了代号一开发者手册,没有这方面的指导。
protected void onMain_AccidentCoverAction(Component c, ActionEvent event) {
String state = findAccidentCover(c).getOn();
Dialog.show("State", state, "OK", null);
}
我也尝试过
protected void onMain_AccidentCoverAction(Component c, ActionEvent event) {
String state = findAccidentCover(c).getComponentState().toString();
Dialog.show("State", state, "OK", null);
}
最佳答案
谷歌搜索,我found this page ,所以您的解决方案可能是:
protected void onMain_AccidentCoverAction(Component c, ActionEvent event) {
boolean state = findAccidentCover(c).isValue();
Dialog.show("State", state ? "On" : "Off", "OK", null);
}
顺便说一句,isValue()
对于该方法来说是一个糟糕的名称。
关于java - 从 codenameone OnOff 开关获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26173683/