当用户按下硬件后退按钮时,我希望我的Codename One对话框被处理掉,我该怎么做?
Dialog dialog = new Dialog("Hi");
dialog.add(new Label("World"));
dialog.show();
答案 0 :(得分:2)
使用空字符串setBackCommand()
命令:
对于没有后退按钮的设备,例如iOS
setDisposeWhenPointerOutOfBounds
final Dialog dialog = new Dialog("Hi");
dialog.add(new Label("World"));
dialog.setBackCommand(new Command(""){
@Override
public void actionPerformed(ActionEvent evt) {
dialog.dispose();
}
});
dialog.setDisposeWhenPointerOutOfBounds(true);
dialog.show();