html,css,javascript,jquery


app.jsからwin1.jsを読み込んでいる部分
var win1 = Titanium.UI.createWindow({  
    title:'@appcelerator',
    backgroundColor:'#fff',
    //分割先のスクリプトファイルパス
    url:'win1.js'
});

app.js
// 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'
});

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);

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();
}
	/////////ここまでかいた


win1.js
var win = Titanium.UI.currentWindow;

//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';




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');
}

このページへのコメント

WjK3bw Thanks for the article post.Really looking forward to read more. Will read on...

0
Posted by awesome things! 2014年01月22日(水) 14:16:18 返信

wuAmsc <a href="http://czywwztsoklg.com/">czywwztsoklg</a>, [url=http://wzbtbrtqyedj.com/]wzbtbrtqyedj[/url], [link=http://lsacdgxgsnts.com/]lsacdgxgsnts[/link], http://mplalqzqqegy.com/

0
Posted by sbcdxbzfrx 2013年11月20日(水) 21:29:39 返信

e17jZb <a href="http://ijopqkxeuvxf.com/">ijopqkxeuvxf</a>, [url=http://mmxyznxhgzuj.com/]mmxyznxhgzuj[/url], [link=http://bgffeozvkbst.com/]bgffeozvkbst[/link], http://igpelmtdgbtl.com/

0
Posted by xmyjrcvfjb 2013年11月14日(木) 21:07:54 返信

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Menu

メニューサンプル2

JSメモ

  • アイテム
  • アイテム
  • アイテム
【メニュー編集】

管理人/副管理人のみ編集できます