您的位置:首页 > 其它

titanium开发教程-02-11增加交互性,在任何view

2012-03-17 01:09 316 查看




 

var win = Titanium.UI.createWindow({
title:"Adding Interactivity to Any View",
backgroundColor:"#FFFFFF",
exitOnClose:true
})

var view = Titanium.UI.createView({
top:0,
left:0,
height:54,
width:"100%",
backgroundColor:"#EEEEEE",
id:"View"
})

var image = Titanium.UI.createImageView({
image:"images/taste-cal.png",
top:0,
left:0,
height:54,
width:36,
id:"Image"
})

var label = Titanium.UI.createLabel({
text:"Taste of California",
top:0,
left:42,
height:54,
width:200,
color:"#000000",
backgroundColor:"orange",
id:"Label"
})

var results = Titanium.UI.createLabel({
text:"Touch the image, label, or view above",
bottom: 24,
height:"auto",
width:"auto",
textAlign:"center"
})

function touchHandler(e){
results.text = e.source.id + " was tapped";
}

function touchMoveHandler(e){
if(e.y > 54){
results.text = "Touch move on window \nx:" + e.x + ", y:" + e.y
}
}

image.addEventListener("touchend", touchHandler);
label.addEventListener("touchend", touchHandler);
view.addEventListener("touchend", touchHandler);
win.addEventListener("touchmove", touchMoveHandler);

view.add(image);
view.add(label);

win.add(view);
win.add(results);

win.open();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: