0
我想從Login.js導航到home.js,以便幫助我解決此問題的任何人。我無法從一個窗口導航到其他
//app.js
var win = Titanium.UI.currentWindow;
var tabbar = Ti.UI.createTabGroup({
title:"Login"
});
var mainwin = Ti.UI.createWindow({
url:"Login/login.js"
});
var signupwin = Ti.UI.createWindow({
url:"Login/Home.js"
});
var tabLogin = Ti.UI.createTab({
title:"Login",
window:mainwin
});
var tabsignup = Ti.UI.createTab({
title:"SignUp",
window:signupwin
});
var nav = Titanium.UI.iPhone.createNavigationGroup({
window:mainwin
});
tabbar.addTab(tabLogin);
tabbar.addTab(tabsignup);
tabbar.open({
transition:Titanium.UI.iPhone.AnimationStyle.CURL_UP
});
//-------------------------------------------------------
//Login.js
//Ti.include('Homescreen/HomeScreen.js');
var win = Ti.UI.currentWindow;
win.title="Login";
var win1 = Titanium.UI.createWindow({
title:'first window',
backgroundColor:'#fff'
});
var lbluser = Ti.UI.createLabel({
text:"UserName",
width: 60,
height: 32,
left: 10,
font:{fontcolor:"blue",fontsize:12},
top: 10
});
win.add(lbluser);
var username = Titanium.UI.createTextField({
color:'#336699',
top:10,
left:50,
width:250,
height:40,
hintText:'Username',
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(username);
var lblpass = Ti.UI.createLabel({
text:"Password",
width: 60,
height: 32,
left: 10,
top: 50,
font:{fontcolor:"white",fontsize:12}
});
win.add(lblpass);
var password = Titanium.UI.createTextField({
color:'#336699',
top:60,
left:50,
width:250,
height:40,
hintText:'Password',
passwordMask:true,
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(password);
var loginBtn = Titanium.UI.createButton({
title:'Login',
top:110,
width:90,
height:35,
borderRadius:1,
font:{fontFamily:'Arial',fontWeight:'bold',fontSize:14}
});
win.add(loginBtn);
/*
Login Button Click Event
*/
loginBtn.addEventListener('click',function(e)
{
if (username.value == 'Bimal' && password.value == 'Pass')
{
alert("ok");
var home = Ti.UI.createWindow({
title:"Home Screen",
url:'Home.js',
_parent:win,
nav:win.nav,
rootWindow:win.rootWindow
});
win.open(home);
}
else
{
alert("Username/Password are required");
}
});
win.open();
//-----------------------------------------------
//Home.js
var win = Titanium.UI.currentWindow;
win.title = "Home Screen";
var username = Titanium.UI.createTextField({
color:'#336699',
top:10,
left:50,
width:300,
height:40,
hintText:'Username',
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(username);
感謝它真的對我很有幫助..... – Anjan 2011-04-27 10:44:15