The following code will create a table view of countries and also added event listener to handle click.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
Titanium.UI.setBackgroundColor('#000'); var tabGroup = Titanium.UI.createTabGroup(); var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Titanium.UI.createTab({ icon:'KS_nav_views.png', title:'Table View', window:win1 }); var dataSource = [{title:"India"}, {title:"China"}, {title:"United States"}, {title:"Japan"}, {title:"Australlia"}, {title:"England"}, {title:"France"}, {title:"Germany"}, {title:"Italy"}, {title:"Switzerland"}, {title:"Sweden"}, {title:"Brazil"}, ]; var table = Titanium.UI.createTableView({data: dataSource}); table.addEventListener('click', function(e){ switch(e.index){ case 0: alert("India"); break; case 1: alert("China"); break; case 2: alert("United States"); break; case 3: alert("Japan"); break; case 4: alert("Australlia"); break; case 5: alert("England"); break; case 6: alert("France"); break; case 7: alert("Germany"); break; case 8: alert("Italy"); break; case 9: alert("Switzerland"); break; case 10: alert("Sweden"); break; case 11: alert("Brazil"); break; } }); win1.add(table); tabGroup.addTab(tab1); tabGroup.open(); |



