titanium开发教程-02-01监听事件

1

 

var win = Titanium.UI.createWindow({
	title:"监听事件",
	backgroundColor:"#FFFFFF",
	exitOnClose:true
});

var img01 = Titanium.UI.createImageView({
	image:"images/box01.png",
	height:75,
	width:75,
	top:24,
	left:24
});

var img02 = Titanium.UI.createImageView({
	image:"images/box02.png",
	height:75,
	width:75,
	top:24,
	right:24
});

var img03 = Titanium.UI.createImageView({
	image:"images/box03.png",
	height:75,
	width:75,
	top:110,
	left:24
});

var img04 = Titanium.UI.createImageView({
	image:"images/box04.png",
	height:75,
	width:75,
	top:110,
	right:24
});

var label = Titanium.UI.createLabel({
	text:"输出结果",
	bottom:100,
	textAlign:"center"
});

img01.addEventListener("click", function(e){
	label.text = e.source.image;//这将打印出图像的地址
});

img02.addEventListener("click", function(e){
	label.text = e.source.image;
});

img03.addEventListener("click", function(e){
	label.text = e.source.image;
});

img04.addEventListener("click", function(e){
	label.text = e.source.image;
});


win.add(img01);
win.add(img02);
win.add(img03);
win.add(img04);
win.add(label);

win.open();
posted @ 2012-03-16 21:56  校长阿四  阅读(537)  评论(0编辑  收藏  举报