Back

Page Viewer

Pager objects using the CreatePageViewer method of the Support object:

 sup.CreatePageViewer( opt );

Example - Test

 app.LoadPlugin( "Support" );
 //Called when application is started.
 function OnStart()
 {
 //Create the main layout.
 lay = app.CreateLayout( "linear", "FillXY" );

 sup = app.CreateSupport();

 Page1();
 Page2();
 Page3();

 pv = sup.CreatePageViewer();
 pv.AddPages( lay1, lay2, lay3 );
 //pv.AddPages2( [lay1, lay2, lay3] );
 pv.SetOnChange( pv_OnChange );

 lay.AddChild( pv );

 //Add layout to app.
 app.AddLayout( lay );
 }

 function pv_OnChange( pos )
 {
  app.ShowPopup( "Page Index: "+pos, "short,bottom" );
 }

 function Page1()
 {
 lay1 = app.CreateLayout( "Linear", "VCenter,FillXY" );
 lay1.SetBackColor( color.RED );

 txt = app.CreateText( "<--Slide--Me--=" );
 txt.SetTextColor( "#FFFFFF" );
 txt.SetTextSize( 50, "sp" );
 lay1.AddChild( txt );

 }

 function Page2()
 {
 lay2 = app.CreateLayout( "Linear", "VCenter,FillXY" );
 lay2.SetBackColor( color.GREEN );

 txt2 = app.CreateText( "Test on seek bar:", 0.7, null, "left" );
 txt2.SetMargins( 0.015, 0, 0, 0.015 );
 txt2.SetTextColor( "#FFFFFF" );
 txt2.SetTextSize( 30, "sp" );
 lay2.AddChild( txt2 );

 skb = app.CreateSeekBar( 0.7 );
 skb.SetColorFilter( color.GREEN_LIGHT_4, "SRC_IN" );
 skb.SetValue( 50 );
 lay2.AddChild( skb );

 }

 function Page3()
 {
 lay3 = app.CreateLayout( "Linear", "VCenter,FillXY" );
 lay3.SetBackColor( color.BLUE );

 btn = app.CreateButton( "Exit", 0.8, 0.25, "custom" );
 btn.SetStyle( "#FAFAFA", "#FAFAFA", 5, "", 0, 5 );
 btn.SetTextColor( "#777777" );
 btn.SetTextSize( 20, "sp" );
 btn.SetOnTouch( btn_OnTouch );
 lay3.AddChild( btn );

 txt3 = app.CreateText( "OR", null, null, "bold" );
 txt3.SetMargins( 0, 0.02, 0, 0.02 );
 txt3.SetTextColor( "#FFFFFF" );
 txt3.SetTextSize( 25, "sp" );
 lay3.AddChild( txt3 );

 btn2 = app.CreateButton( "Go To Page: 1", 0.8, 0.15, "custom" );
 btn2.SetStyle( "#FAFAFA", "#FAFAFA", 5, "", 0, 5 );
 btn2.SetTextColor( "#777777" );
 btn2.SetTextSize( 20, "sp" );
 btn2.SetOnTouch( btn2_OnTouch );
 lay3.AddChild( btn2 );

 }

 function btn_OnTouch()
 {
  app.Exit();
 }

 function btn2_OnTouch()
 {
  pv.SetCurrentPage( 0 );
 }
  Copy   Copy All    Run   

Example - Carousel

 app.LoadPlugin( "Support" );

//Called when application is started.
function OnStart()
{
 //Create the main layout.
 lay = app.CreateLayout( "Linear", "Center,FillXY" );
 lay.SetBackColor( "#FAFAFA" );

 sup = app.CreateSupport();

 img1 = app.CreateLayout( "Linear", "FillX" );
 img1.SetBackground( "/Sys/Img/GreenBack.jpg" );
 img1.AddChild( app.CreateText( "Page1", 1, null, "bold" ) );

 img2 = app.CreateLayout( "Linear", "FillX" );
 img2.SetBackground( "/Sys/Img/BlueBack.jpg" );
 img2.AddChild( app.CreateText( "Page2", 1, null, "bold" ) );

 img3 = app.CreateLayout( "Linear", "FillX" );
 img3.SetBackground( "/Sys/Img/BlackBack.jpg" );
 img3.AddChild( app.CreateText( "Page3", 1, null, "bold" ) );

 pv = sup.CreatePageViewer();
 pv.AddPages( img1, img2, img3 );
 pv.SetSize( 1, 0.5 );

 lay.AddChild( pv );

 //Add layout to app.
 app.AddLayout( lay );
 setInterval( NextPage, 1500 );
}
function NextPage()
{
 if( pv.GetCurrentPage() == 2 ) pv.SetCurrentPage( 0 );
 else pv.NextPage();
}
  Copy   Copy All    Run   

The following methods are available on the Pager object:

 GetType()
 AddPages( object, object, ... )
 AddPages2( [object, object, ...] )
 SetOnChange( function )
 GetCurrentPage()
 SetCurrentPage( index )
 PreviousPage()
 NextPage()