titanium开发教程-02-02创建按钮

1

 

var win = Titanium.UI.createWindow({
	title:"创建按钮",
	backgroundColor:"#FFFFFF",
	exitOnClose:true
});

var simpleButton = Titanium.UI.createButton({
	title:"按住我",
	width:"25%",	
	height:"10%",
	top:"10%",
	id:"Simple Button",	
})

var customButton = Titanium.UI.createButton({
	title:"按住我",
	backgroundImage:"images/button.png",
	backgroundSelectedImage:"images/button-over.png",
	width:"25%",
	height:"10%",
	bottom:"10%",
	id:"Custom Button"
});

simpleButton.addEventListener("click", function(e){
	//e 是 事件本身
	alert(e.source.id + " fired a " + e.type + " event");
});

customButton.addEventListener("touchend", function(e){

	alert(e.source.id + " fired a " + e.type + " event");
});

win.add(simpleButton);
win.add(customButton);

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