[英]How to dispose a Dialog with the back Button
I would like my Codename One Dialog to get disposed when the User presses on the hardware back button, how would I do that? 当用户按下硬件后退按钮时,我希望我的Codename One Dialog被处理掉,我该怎么做?
Dialog dialog = new Dialog("Hi");
dialog.add(new Label("World"));
dialog.show();
Use the setBackCommand()
with an empty string Command: It is also recommended to use the setDisposeWhenPointerOutOfBounds
for devices that does not have a back Button such as iOS 使用带有空字符串的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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.