我已经创建了对话框,并且我想在用户从dialoge中按“确定”按钮时调用一个函数。但是似乎该函数没有调用单击“确定”按钮。这是我的代码
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
试试这个:
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 )
保持编码....... :)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句