This shows you the differences between two versions of the page.
— |
sample_code:tab-select [2014/12/17 15:25] (current) octazid created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Tab-Select ====== | ||
+ | (Sample Code taken from the DroidScript Google-Group) | ||
+ | <code JavaScript tab_select.js> | ||
+ | function OnStart() | ||
+ | { | ||
+ | //Create a layout with objects vertically centered. | ||
+ | lay = app.CreateLayout( "linear", "VCenter,FillXY" ); | ||
+ | | ||
+ | //Create tabs. | ||
+ | tabs = app.CreateTabs( "FRED,BILL,MARK", 0.8, 0.8, "VCenter" ); | ||
+ | tabs.SetOnChange( tabs_OnChange ); | ||
+ | lay.AddChild( tabs ); | ||
+ | | ||
+ | //Add button to first tab. | ||
+ | layFred = tabs.GetLayout( "FRED" ); | ||
+ | btn = app.CreateButton( "Choose Mark" ); | ||
+ | btn.SetOnTouch(btnOnTouch); | ||
+ | layFred.AddChild( btn ); | ||
+ | | ||
+ | //Add button to second tab. | ||
+ | layBill = tabs.GetLayout( "BILL" ); | ||
+ | chk = app.CreateCheckBox( "CheckBox" ); | ||
+ | layBill.AddChild( chk ); | ||
+ | | ||
+ | //Add layout to app. | ||
+ | app.AddLayout( lay ); | ||
+ | } | ||
+ | //Handle tab selection. | ||
+ | function tabs_OnChange( name ) | ||
+ | { | ||
+ | app.ShowPopup( name ); | ||
+ | } | ||
+ | |||
+ | function btnOnTouch() | ||
+ | { | ||
+ | tabs.ShowTab("MARK") | ||
+ | } | ||
+ | </code> |