对话框(提示对话框与输入对话框)
以下是可以添加“多个按钮的提示框”:
local function onButtonClicked(event)
print(event.buttonIndex)
if event.buttonIndex == 3 then print("单击了第三个按钮") end
--[[ if event.buttonIndex == 1 then --判断玩家单击的按钮索引
print("玩家选择了 YES 按钮")
else
print("玩家选择了 NO 按钮")
end
]]
end
回调: device.showAlert("Confirm Exit", "Are you sure exit game ?", {"YES", "NO","退出对话框"}, onButtonClicked)
以下是“输入对话框与返回”:
local input=device.showInputBox("标题","我是提示信息", "我是默认值")--提示框
if tonumber(input)==2 then --转换输入的内容为数字进行比较哦
print("true")
else
print("false")
end