Toolbar.getBackButton 代号一
Toolbar.getBackButton on Codename One
为了在使用 .getToolbar().setBackCommand(...)
创建后操作 BackButton,我需要获取它,所以我创建了以下代码:
public static final boolean isAndroidTheme = UIManager.getInstance().isThemeConstant("textComponentOnTopBool", false);
if (isAndroidTheme) {
originalBackButton = this.getToolbar().getComponentAt(1);
} else {
originalBackButton = this.getToolbar().getComponentAt(2);
}
它有效,但我担心它的可靠性如何。有没有可能做得更好或者这段代码没问题?
setBackCommand
或者 returns 这样的命令:
public Command setBackCommand(String title, ActionListener<ActionEvent> listener)
或者接受 Command
作为方法的参数。获得命令后,您可以使用 Button b = toolbar.findCommandComponent(cmd);
.
找到适用的组件
为了在使用 .getToolbar().setBackCommand(...)
创建后操作 BackButton,我需要获取它,所以我创建了以下代码:
public static final boolean isAndroidTheme = UIManager.getInstance().isThemeConstant("textComponentOnTopBool", false);
if (isAndroidTheme) {
originalBackButton = this.getToolbar().getComponentAt(1);
} else {
originalBackButton = this.getToolbar().getComponentAt(2);
}
它有效,但我担心它的可靠性如何。有没有可能做得更好或者这段代码没问题?
setBackCommand
或者 returns 这样的命令:
public Command setBackCommand(String title, ActionListener<ActionEvent> listener)
或者接受 Command
作为方法的参数。获得命令后,您可以使用 Button b = toolbar.findCommandComponent(cmd);
.