device.showAlert 3.10版本被去掉了 请问安卓弹确认取消窗口有其他成熟方案吗
function device.showAlert(title, message, buttonLabels, listener)
if type(buttonLabels) ~= "table" then
buttonLabels = {tostring(buttonLabels)}
else
table.map(buttonLabels, function(v) return tostring(v) end)
end
if DEBUG > 1 then
printInfo("device.showAlert() - title: %s", title)
printInfo(" message: %s", message)
printInfo(" buttonLabels: %s", table.concat(buttonLabels, ", "))
end
if device.platform == "android" then
local tempListner = function(event)
if type(event) == "string" then
event = require("framework.json").decode(event)
event.buttonIndex = tonumber(event.buttonIndex)
end
if listener then listener(event) end
end
luaj.callStaticMethod("org/cocos2dx/utils/PSNative", "createAlert", {title, message, buttonLabels, tempListner}, "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Vector;I)V");
else
local defaultLabel = ""
if #buttonLabels > 0 then
defaultLabel = buttonLabels[1]
table.remove(buttonLabels, 1)
end
cc.Native:createAlert(title, message, defaultLabel)
for i, label in ipairs(buttonLabels) do
cc.Native:addAlertButton(label)
end
if type(listener) ~= "function" then
listener = function() end
end
cc.Native:showAlert(listener)
end
end
cc.Native C++源码里面也找不到了