// this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000'); // create tab group var tabGroup = Titanium.UI.createTabGroup(); // // create base UI tab and root window // var win1 = Titanium.UI.createWindow({ title:'@appcelerator', backgroundColor:'#fff' }); var tableView = Titanium.UI.createTableView(); win1.add(tableView); var url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=appcelerator'; if(Titanium.Network.online != false){ var xhr = Titanium.Network.createHTTPClient(); xhr.open('GET',url,false); xhr.onload = function(){ //受け取ったJSONデータをパース var json = JSON.parse(this.responseText); for(var i=0; i<json.length; i++){ var row = Titanium.UI.createTableViewRow(); row.className = 'tweet'; row.height = 180; row.add(Titanium.UI.createLabel({ text:json[i].user.screen_name, top:8, left:64, //width:300, height:16 })); row.add(Titanium.UI.createLabel({ text:json[i].text, top:32, left:64, width:256, height:'auto' })); row.add(Titanium.UI.createImageView({ image:json[i].user.profile_image_url, top:8, left:8, width:48, height:48 })); tableView.appendRow(row); } }; //error xhr.onerror = function(error){ //error message alert(error); }; //send xhr.send(); }else{ //error alert('offline'); } var tab1 = Titanium.UI.createTab({ icon:'dark_appcelerator.png', title:'@appcelerator', window:win1 }); // // create controls tab and root window // var win2 = Titanium.UI.createWindow({ title:'@appcelerator_ja', backgroundColor:'#fff' }); var tab2 = Titanium.UI.createTab({ icon:'dark_appcelerator.png', title:'@appcelerator_ja', window:win2 }); var label2 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win2.add(label2); // // create controls tab and root window // var win3 = Titanium.UI.createWindow({ title:'#Titanium', backgroundColor:'#fff' }); var tab3 = Titanium.UI.createTab({ icon:'dark_pegman.png', title:'#Titanium', window:win3 }); var label3 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win3.add(label3); // // create controls tab and root window // var win4 = Titanium.UI.createWindow({ title:'TitaniumJP', backgroundColor:'#fff' }); var tab4 = Titanium.UI.createTab({ icon:'dark_pegman.png', title:'TitaniumJP', window:win4 }); var label4 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win4.add(label4); var tab5 = Titanium.UI.createTab({ icon:'dark_search.png', title:'検索', window: Titanium.UI.createWindow({ title:'検索', backgroundColor:'#fff' }) }); // // add tabs // tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.addTab(tab3); tabGroup.addTab(tab4); tabGroup.addTab(tab5); // open tab group tabGroup.open(); if(Titanium.Network.online == false){ alert('offline'); }else{ var xhr = Titanium.Network.createHTTPClient(); var url = "http://www.appcelerator.com/"; //接続 xhr.open('GET',url,false); //レスポンツを受け取るイベント(非同期に実行される) xhr.onload = function(){ //Titanium Developerの画面にログを出力する Titanium.API.info(xhr.responseText); } xhr.onerror = function(error){ //error message }; //リクエストを送信 xhr.send(); } /////////ここまでかいた
コメントをかく