| 语法: |
nodeLib.setOnMsgNotify(callback) |
|
| 参数 |
类型 |
说明 |
| callback |
函数类型 |
当节点事件触发的时候会触发此函数 |
| return |
布尔类型 |
触发成功返回︰true 触发失败返回︰false |
| 注意事项 |
|
import('android.*')import('java.lang.*')import('java.util.*')import('android.widget.*')import('android.content.Intent')import('android.content.Context')import('com.nx.assist.lua.LuaEngine')local context = LuaEngine.getContext()function post(callback) --切换到原生UI线程执行指定函数LuaEngine.runOnUIThread(Runnable{run = callback})Thread.sleep(100)end--[===[监听原生吐司或者状态栏信息弹出]===]local r = nodeLib.setOnMsgNotify(function(what,msg)if what == 1 then --原生吐司或者状态栏变化print(what,msg)endend)function 测试吐司()while true dopost(function()Toast.makeText(context, "我是原生吐司", Toast.LENGTH_SHORT).show()end)sleep(2000)endendif r then测试吐司()elseprint("监听失败")end