我创建了对话框,当用户从dialoge按下ok按钮时我想调用一个函数。但似乎函数没有调用单击确定按钮。这是我的代码
local alert = native.showAlert( "TapNTrack", "You Lost", "OK", onComplete )
local function onComplete(event)
print("oncomplete");
if "clicked" == event.action then --1
local i = event.index --2
if i == 1 then
gotoLevels()
end --2
end-- 1
end
答案 0 :(得分:3)
试试这个:
local function onComplete( event )
if "clicked" == event.action then
local i = event.index
if 1 == i then
print("OK")
elseif 2 == i then
print("Cancel")
end
end
end
local alert = native.showAlert( "Title", "Message", { "OK", "Cancel" }, onComplete )
保持编码................:)