How to use tableView in Titanium, iPhone or ANDROID?

By | April 28, 2011

This tutorial shows how to create a tableview in Titanium and add data to it.
How to handle a click function in the tableView and get the data from the row.

   /* Create a new window */
   var win = Titanium.UI.createWindow({

	/* Datasource for the tableView */
    var my_data = [

    var tableview = Titanium.UI.createTableView({

	/* Alternately you can use this to set the datasource in the tableView.

	/* this will handle the click function in the tableView */
	tableview.addEventListener('click', function(e)
		e.rowData.hasCheck = true;		 // add a checkmark to the row.
		var title = e.rowData.title;	       // get the title property of the clicked row.
                var index = e.index;                     // got the clicked index;
      "Clicked on index : " + index + "with row title : " + title);

	win.add(tableview); 				// add the tableview to the window.;							// open the window.

Please leave your valuable comments.

Leave a Reply

Your email address will not be published. Required fields are marked *