我是 Titanium appcelerator 编程的新手。我怀疑按钮单击是否事件在第一个屏幕上运行良好,之后当我单击该按钮转到第二个屏幕时。第二个屏幕由一个按钮组成,当我单击该按钮时它导航到第三个屏幕.但是按钮单击事件在第二个屏幕中不起作用。
我在两个屏幕中编写了相同的代码,如下所示:
请告诉我哪里做错了。
第一个屏幕:
Ti.include("Files/MainScreen.js");
var win = Titanium.UI.createWindow({
title:'My Window',
backgroundColor:'#cccccc'
});
win.open();
var itemView = Titanium.UI.createView({
title:'',
backgroundImage:'splash.png',
height:'768',
width:'1024'
});
// Eventlistener
itemView.addEventListener('click',function(e) {
var newWindow = Ti.UI.createWindow({
background : "#000",
title : "Image View",
url:"Files/MainScreen.js"
});
newWindow.open(win,{animated:true});
});
win.add(itemView);
win.orientationModes=[Titanium.UI.LANDSCAPE_LEFT];
win.open();
MainScreen.js:
Ti.include("CustomerScreen.js");
var win = Titanium.UI.createWindow({
title:'My Window',
backgroundColor:'#cccccc',
leftNavButton:btnCancel
});
var btnCancel = Titanium.UI.createButton({
title:'Cancel'
});
var image = Ti.UI.createImageView({
image:'main_screen.png'
});
win.add(image);
win.open();
var custbutton=Titanium.UI.createButton({
title:'customer',
top:200,
bottom:300,
left:90,
height:'235',
width:'235',
backgroundColor:"#000"
});
custbutton.addEventListener('click',function alertingcustomer () {
var newWindow1 = Ti.UI.createWindow({
background : "#000",
title : "",
url:"Files/CustomerScreen.js"
});
newWindow1.open(win,{animated:true});
});
win.add(custbutton);
win.open();
CustomerScreen.js
var win = Titanium.UI.createWindow({
title:'Window',
backgroundColor:'#cccccc',
modal:true
});
win.open();