Titaniun源代码:
// 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:'Tab 1', backgroundColor:'#fff' }); var tab1 = Titanium.UI.createTab({ icon:'KS_nav_views.png', title:'Tab 1', window:win1 }); var label1 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 1', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win1.add(label1); // // create controls tab and root window // var win2 = Titanium.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff' }); var tab2 = Titanium.UI.createTab({ icon:'KS_nav_ui.png', title:'Tab 2', window:win2 }); var lblName = Titanium.UI.createLabel({ color:'#999', text:'姓名', shadowColor:'#aaa', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', height: 20, width:45, top:10, left:10 }); var txtName=Titanium.UI.createTextField({ color:'#336699', height:35, top:10, left:55, width:100, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); var lblPassword = Titanium.UI.createLabel({ color:'#999', text:'密码', shadowColor:'#aaa', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', height: 20, width:45, top:60, left:10 }); var txtPassword=Titanium.UI.createTextField({ color:'#336699', height:35, top:60, left:55, width:100, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); var btnSubmit=Titanium.UI.createButton({ title:'提交', top:10, width:100, height:50, left:200 }); btnSubmit.addEventListener('click',function(e){ var userName=txtName.value; var passWord=txtPassword.value; //REST服务路径 var url="http://123.123.101.30:8080/RestWebService/service/restWS/rest?userName="+userName+"&password="+passWord; //使用Httpclient请求相关的REST服务 var client=Ti.Network.createHTTPClient({ //成功回调函数
onload:function(e){ Ti.API.info("Received text :" +this.responseText); alert("成功:"+this.responseText); }, onerror:function(e){ Ti.API.debug(e.toLocaleString); alert('errror'); }, timeout:5000 }); //设置请求方式 client.open('GET',url); //发送相关的请求 client.send(); }); win2.add(lblName); win2.add(txtName); win2.add(lblPassword); win2.add(txtPassword); win2.add(btnSubmit); // // add tabs // tabGroup.addTab(tab1); tabGroup.addTab(tab2); // open tab group tabGroup.open();