类型 功能 库 widget.* 返回值 无 修订版 2024.3703 版 关键词 widget、tab 栏、TabBarWidget、setSelected 另请参见 widget.newTabBar() TabBarWidget
使用此方法将特定的 TabBarWidget 按钮设为其“已选择”状态。您也可以同时调用按钮的 onPress
侦听器。
object:setSelected( buttonIndex ) object:setSelected( buttonIndex, simulatePress )
Boolean。如果设为 true
,则由 buttonIndex
指定的选项卡按钮将调用其 onPress
侦听器函数。默认值为 false
,这意味着选项卡按钮将显示为“已选择”状态,但不会调用侦听器函数。
-- Select the third tab tabBar:setSelected( 3 ) -- Select the second tab button and invoke its listener function tabBar:setSelected( 2, true )