var win = Titanium.UI.currentWindow; var tableView = Titanium.UI.createTableView(); win.add(tableView); //@appceleratorのtweetを取得 var url = 'http://search.twitter.com/search.json'; var refreshTimeline = function(){ //alert("読み込むよ!"); if(Titanium.Network.online != false){ //HTTPclientオブジェクト生成 var xhr = Titanium.Network.createHTTPClient(); xhr.open('GET',url,false); //レスポンスを受け取るイベント(非同期に実行させる) xhr.onload = function(){ //表示内容をいったんクリアする tableView.data = []; //受け取ったJSONデータをパース var json = JSON.parse(this.responseText); //JSON構造が違うため、json.lengthではなく、json.results.length for(var i=0; i<json.results.length; i++){ var tweet = json.results[i]; tweet.user = {}; tweet.user.screen_name = tweet.from_user; tweet.user.name = tweet.from_user; tweet.user.profile_image_url = tweet.profile_image_url; //ここからは基本的に同じ var row = Titanium.UI.createTableViewRow(); row.height = 180; row.add(Titanium.UI.createLabel({ //tweet変数を経由して取得する text:tweet.user.screen_name, top:8, left:64, height:16 })); row.add(Titanium.UI.createLabel({ text:tweet.text, top:32, left:64, width:256, height:'auto' })); row.add(Titanium.UI.createImageView({ image:tweet.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({ q:'#Titanium', lang:'ja', locale:'ja' }); }else{ //error alert('offline'); } } refreshTimeline(); //ウィンドウの右上のボタンを設定 var rightButton = Titanium.UI.createButton({ //title:'再読込' systemButton:Titanium.UI.iPhone.SystemButton.REFRESH }); win.rightNavButton = rightButton; rightButton.addEventListener('click',function(){ //alert('onbt'); refreshTimeline(); });
// 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', //分割先のスクリプトファイルパス url:'win1.js' }); /* win1.oneMoreThing = true; win1.open(); */ //customという名前のカスタムイベントを受け取り処理する /* Titanium.App.addEventListener('custom',function(e){ var test1 = Ti.API.info(e.message); var test2 = Ti.API.info(e.profile.name); alert(test1); alert(test2); }); */ Titanium.App.addEventListener('custom',function(e){ //イベント引数として受け取るのではなくアプリケーションプロパティを利用 var test3 = Titanium.API.info(Ti.App.Properties.getString('message')); //alert(test3); }) 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', url:'win3.js' }); 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); Titanium.include('tab5.js'); // // 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(); } /////////ここまでかいた
var win = Titanium.UI.currentWindow; //app.jsからの値の取得 //alert(Titanium.UI.currentWindow.oneMoreThing); //app.jsへ値を渡す /* Titanium.App.fireEvent('custom',{ message:'イベントメッセージ', profile:{ name:'ネストしたデータも引き渡せます', memo1:'しかしfunctionなどは渡せません', memo2:'そのため子windowのコントロールを外部から操作できません' } }) */ Titanium.App.Properties.setString('message','プロパティのメッセージ'); Titanium.App.fireEvent('custom',{}); //TableViewの追加 var tableView = Titanium.UI.createTableView(); win.add(tableView); //@appceleratorのtweetを取得 var url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=appcelerator'; var refreshTimeline = function(){ //alert("読み込むよ!"); if(Titanium.Network.online != false){ //HTTPlientオブジェクト生成 var xhr = Titanium.Network.createHTTPClient(); xhr.open('GET',url,false); //レスポンスを受け取るイベント(非同期に実行させる) xhr.onload = function(){ //受け取ったJSONデータをパース var json = JSON.parse(xhr.responseText); for(var i=0; i<json.length; i++){ var row = Titanium.UI.createTableViewRow(); row.height = 180; row.add(Titanium.UI.createLabel({ text:json[i].user.screen_name, top:8, left:64, 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'); } } refreshTimeline(); //ウィンドウの右上のボタンを設定 var rightButton = Titanium.UI.createButton({ //title:'再読込' systemButton:Titanium.UI.iPhone.SystemButton.REFRESH }); win.rightNavButton = rightButton; rightButton.addEventListener('click',function(){ //alert('onbt'); refreshTimeline(); });
このページへのコメント
l73d4E Muchos Gracias for your article post. Want more.
LWDi5j <a href="http://gljwgajitdvf.com/">gljwgajitdvf</a>, [url=http://czygkjohbiky.com/]czygkjohbiky[/url], [link=http://rntseunakwzf.com/]rntseunakwzf[/link], http://xjcuprktkjeq.com/
kjBZgx <a href="http://critizvsvqli.com/">critizvsvqli</a>, [url=http://lqaljxqirmbm.com/]lqaljxqirmbm[/url], [link=http://uvufigrwgdbd.com/]uvufigrwgdbd[/link], http://sexlwxwfzxpl.com/