0
嗨我需要創建一個應用程序,使用Android系統,然後登錄,因爲你有正確的憑據去標籤窗口。Appcelerator Titanium Android登錄並轉到標籤
我有這個代碼在app.js進行身份驗證,它現在工作正常,但我還沒有設法創建標籤結構。
var win = Ti.UI.createWindow({
backgroundColor: '#096594',
title: 'ACCESS CONFIG',
layout:'vertical',
navBarHidden:true,
fullscreen:false,
exitOnClose:true
});
var my_navbar = Ti.UI.createLabel({
height:20,
backgroundColor:'#989898',
color:'#fff',
text:' ACCESS CONFIG',
top:0,
width:'100%',
font:{fontSize:11,fontWeight:'normal'},
marginleft:10
});
win.add(my_navbar);
win.add(Ti.UI.createLabel({
top:10,
height:15,
left:10,
right:5,
color:'#fff',
textAlign:'left',
text:'Usuario: [Userid]',
font:{fontSize:12},
bottom:5
}));
var txtUserid = Ti.UI.createTextField({
value:'1',
hintText:'user ID',
height:35,
left:5,
right:5,
font:{fontSize:12},
color:'#a2a2a2',
borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(txtUserid);
win.add(Ti.UI.createLabel({
top:2,
height:17,
left:10,
right:5,
color:'#fff',
textAlign:'left',
text:'Name: [Login]',
font:{fontSize:12},
bottom:5
}));
var txtLogin = Ti.UI.createTextField({
value:'M',
hintText:'Username',
height:35,
left:5,
right:5,
font:{fontSize:12},
color:'#a2a2a2',
borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(txtLogin);
win.add(Ti.UI.createLabel({
top:2,
height:17,
left:10,
right:5,
color:'#fff',
textAlign:'left',
text:'Password: [Password]',
font:{fontSize:12},
bottom:5
}));
var txtPassword = Ti.UI.createTextField({
value:'111',
hintText:'Contraseña',
passwordMask:true,
height:35,
left:5,
right:5,
font:{fontSize:12},
color:'#a2a2a2',
borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(txtPassword);
win.add(Ti.UI.createLabel({
top:10,
height:0,
left:5,
right:5,
color:'#000',
textAlign:'left',
text:'Authentication Url:',
font:{fontSize:18}
}));
var txtUrl = Ti.UI.createTextField({
value:'http://',
hintText:'Url to connect with data',
height:0, left:5, right:5,
borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(txtUrl);
var yesButton = Ti.UI.createButton({
title:'Connect with DATA',
top:5,
height:37,
left:85,
right:85,
color:'#fff',
backgroundColor:'#406a83',
borderColor:'#688a9d',
borderWidth:1,
borderRadius:5,
borderStyle:Ti.UI.INPUT_BORDERSTYLE_BEZEL
});
win.add(yesButton);
yesButton.addEventListener('click', clickYesButton);
function clickYesButton(e) {
var button = e.source;
var xhr=Titanium.Network.createHTTPClient();
xhr.onerror = function(e){alert('Error: '+e.error);};
xhr.onload = function() {alert(this.responseText);};
xhr.open("POST",txtUrl.value);//ADD your URL
var param={"userid":txtUserid.value,"login":txtLogin.value,"password":txtPassword.value};
Ti.API.info('Params'+JSON.stringify(param));
xhr.send(param);
}
win.open();