AlertType类中有五个静态数据成员,这是预定义的AlertType类型,提供给Alert类使用。它们是:
(1)AlertType.ALARM 警报
(2)AlertType.CONFIRMATION 确认
(3)AlertType.ERROR 错误
(4)AlertType.INFO 提示信息
(5)AlertType.WARNING 警告
AlertType类中只有一个方法:boolean playSound(Display
display),可以根据以上几种类型来发出声音。例如AlertType.ERROR.playSound(display)语句将发出“错误”类型的声音。
Alert类似于J2SE中的对话框,它有两个构造方法:
(1)Alert(String title)
(2)Alert(String title, String alertText, Image alertImage, AlertType
alertType)
可以使用下面的方法来取得或设置构造方法中的参数:
String getString()/void setString(String str)
Image getImage()/void
setImage(Image img)
AlertType getType()/void setType(AlertType type)
Alert实例的特征就是在显示一段时间后就会跳回原来的画面,这个时间间隔可以使用方法
void setTimeout(int
time)类设置(如果使用Alert.FOREVER作为参数,那么它将一直显示直到用户按下解除键才消失),也可以使用方法int
getTimeout()来获得。
Alert类还有一个静态数据成员Alert.DISMISS_COMMAND,它的作用是什么呢?如果没有使用addCommand(Command
c)方法在Alert上加入系统菜单,那么Alert就会将Alert.DISMISS_COMMAND作为它的系统菜单,它传给commandAction(...)方法的第一个参数就是Alert.DISMISS_COMMAND;一旦有别的Command实例存在,Alert.DISMISS_COMMAND就消失了,它们是不共存的。
如果没有设定Alert事件的事件处理方法,那么不管是哪种菜单,画面都会回到上一页。
protected void showConfirmation(String title, String text, final int type) {
Form form = new Form("");
Alert alert = new Alert(title, text, null, AlertType.CONFIRMATION);
alert.addCommand(new Command("Yes", Command.OK, 1));
alert.addCommand(new Command("No", Command.CANCEL, 1));
alert.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable d) {
if (c.getLabel().equals("Yes")) {
if (type == 0) {
} else if (type == 1) {
} else if (type == 2) {
}
} else if (c.getLabel().equals("No")) {
gotoForm();
} else if (c.getLabel().equals("确定")) {
}
}
});
Display.getDisplay(this).setCurrent(alert, form);
}
}
分享到:
相关推荐
Xam-Forms-CustomAlert Xamarin表单中的自定义提醒。 用法: 从ViewModel绑定值: xmlns:control="clr-namespace:CustomAlert.Controls;... AlertType="{Binding Alert}" Description="{Binding Description}
receivedMessage = new Alert("接收到的小区广播消息", null, null, AlertType.INFO); receivedMessage.setTimeout(Alert.FOREVER); receivedMessage.addCommand(exitCommand); receivedMessage....
一行代码实现提示,也可根据自己的...config.alertType = type; //显示 [XXAlertView showAlert:title inView:[UIApplication sharedApplication].keyWindow withConfig:[XXAlertViewConfig defaultConfig]];
ZAlertView-用Swift编写的AlertView介绍ZAlertView是一个高度... public enum AlertType : Int { case Alert case Confirmation case MultipleChoice } 要创建并显示对话框,首先,在文件的开头导入模块: import ZAler
const { writeCdrs , queryCdrs , writeAlerts , queryAlerts , AlertType} = require ( '@jambonz/time-series' ) ( pinoLogger , '172.32.10.44' ) ;await writeCdrs ( [ { from : 'me' , to : 'you' , sip_...
_popViewController.alertType = AlertViewTypeRounded; _popViewController.showCloseButton = YES; _popViewController.cornerValue = 10.0;[_popViewController showInView:self.view title:@"Lipsum!?" message...
GlowmarktApi.Net ...Glowmarkt Api端点文档 用户 帐户 ...AlertType 警报 模板 内容 常问问题 语言内容 Swift的 提示类型 用户提示 技术支持 条款及细则 条款和条件用户 UserAction UserActionType