Can someone provide simple string

Discussion in 'Jiggy Runtime Development' started by The Ax, Apr 20, 2008.

  1. The Ax

    The Ax Banned

    Joined:
    Mar 11, 2008
    Messages:
    647
    Likes Received:
    22
    Ok,
    What i cant figure out how to do is make so when I tap one of the selections it loads new page in this code
    Code:
    Plugins.load( "UIKit" );
    
    var states = 
      [
        "Alabama","Alaska","Arizona","Arkansas",
        "California","Colorado","Connecticut",
        "Delaware",
        "Florida",
        "Georgia",
        "Hawaii",
        "Idaho","Illinois","Indiana","Iowa",
        "Kansas","Kentucky",
        "Louisiana",
        "Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana",
        "Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota",
        "Ohio","Oklahoma","Oregon",
        "Pennsylvania",
        "Rhode Island",
        "South Carolina","South Dakota",
        "Tennessee","Texas",
        "Utah",
        "Vermont","Virginia",
        "Washington","West Virginia","Wisconsin","Wyoming",
      ];
    
    // This function will help us build the list of section titles
    // as well as the first row of each section - which we need to
    // give to the section list later.
    
    var sectionTitles = [];
    
    var sectionRows = [];
    
    for( var i = 0; i < states.length; i++ )
    {
      var firstLetter = states[ i ].charAt( 0 );
      
      var sectionStart = false;
      
      if ( sectionTitles.length == 0 )
        sectionStart = true;
      else 
        sectionStart = firstLetter != sectionTitles[ sectionTitles.length - 1 ];
        
      if ( sectionStart )
      {
        sectionTitles.push( firstLetter );
        sectionRows.push( i );
      }    
    }
     
    // On to the standard set-up 
    
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor=[1 , 1 , 1 , 1];
     
    var mainView = new UIView( window.bounds );
    
    window.setContentView( mainView );
    
    // Create a UISectionList
    
    var sl = new UISectionList( mainView.bounds );
    
    mainView.addSubview( sl );
    
    // Get the table from the section list so we can prepare it
    
    var table = sl.table;
    
    // Formality - we need to add a table column
    
    table.addTableColumn( new UITableColumn( "foo" , "bar" , sl.bounds[ 2 ] ) );
    
    // Customize the look a little bit
    
    table.separatorStyle = 1;
    
    table.rowHeight = 48;
    
    // Now, let's create the cells
    
    var cells = [];
    
    for( var i = 0; i < states.length; i++ )
    {
      var cell = new UIImageAndTextTableCell();
      cell.title = states[ i ];
      
      cells.push( cell );
    }
    
    // Attach all the event handlers
    
    sl.onGetNumberOfSections =  function( l ) { return sectionTitles.length; };
    
    sl.onGetSectionTitle = function( l , section ) { return sectionTitles[ section ]; };
    
    // This should return the first row for the given section - we prepared them
    // above.
    
    sl.onGetSectionRow = function( l , section ) { return sectionRows[ section ]; };
    
    sl.onGetNumberOfRows = function( l ) { return cells.length; };
    
    sl.onGetCell = function( l , column , row ) { return cells[ row ]; };
    
    sl.onRowSelected = function( l , row ) { log( "SELECTED:" + states[row] ); };
    
    // Now tell the section list to load the data
    
    sl.reloadData();
    
    // We could turn off the index this way:
    //sl.setIndexVisible( false );
    
    // This makes the section titles black and the current section 
    // title transparent.
    //sl.setSectionListStyle( 1 );
    

Share This Page