在活动文件添加以下函数,这些函数可以在活动的特定状态执行。
function main(…)
–…:newActivity传递过来的参数。
print(“入口函数”,…)
end
function onCreate()
print(“窗口创建”)
end
function onStart()
print(“活动开始”)
end
function onResume()
print(“返回程序”)
end
function onPause()
print(“活动暂停”)
end
function onStop()
print(“活动停止”)
end
function onDestroy()
print(“程序已退出”)
end
function onResult(name,…)
–name:返回的活动名称
–…:返回的参数
print(“返回活动”,name,…)
end
function onCreateOptionsMenu(menu)
–menu:选项菜单。
menu.add(“菜单”)
end
function onOptionsItemSelected(item)
–item:选中的菜单项
print(item.Title)
end
function onConfigurationChanged(config)
–config:配置信息
print(“屏幕方向关闭”)
end
function onKeyDown(keycode,event)
–keycode:键值
–event:事件
print(“按键按下”,keycode)
end
function onKeyUp(keycode,event)
–keycode:键值
–event:事件
print(“按键抬起”,keycode)
end
function onKeyLongPress(keycode,event)
–keycode:键值
–event:事件
print(“按键长按”,keycode)
end
function onTouchEvent(event)
–event:事件
print(“触摸事件”,event)
end
请登录后查看评论内容