如何通过按下Titce Appcelerator中的另一个按钮来创建按钮?
问题描述:
我的问题很可怕,我很抱歉。如何通过按下Titce Appcelerator中的另一个按钮来创建按钮?
所以我想要做的是进入createNewCourseScreen,输入名称并设置颜色并按下创建按钮,创建的按钮将在coursesScreen中的其他按钮下弹出。
我是钛金属的meganoob,需要你的帮助!
屏幕 coursesScreen:http://s30.postimg.org/do1jrlrrl/courses.png newCourseScreen:http://s29.postimg.org/7c15cxnon/newcourse.png
答
你可能会在这个思维过程复杂化。也许你正在使用Alloy,在看到如何实现这一点时不那么直接。在传统的Titanium中,你已经有了代码来展示如何创建按钮和事件监听器盯着你。
一般步骤: 1 - 获取标题和颜色的输入。 2 - 调用onClick或addEventListener('click',...处理程序创建按钮 3 - 在处理此事件的函数中,使用Ti.UI.createButton创建一个按钮 4 - 创建一个事件侦听器。它 5 - 添加按钮,你想让它显示在屏幕
经典:
// Using the same logic that created the other buttons
function createButtonPress(){
// Store information about new button created somewhere so that it
// shows up the next time the application is run.
// Create the button.
var newButton = Ti.UI.createButton({
title: nameFromTextField.value
color: colorFromTextField.value
});
newButton.addEventListener('click', function(){
// Thing you want the new button to do when pressed.
});
viewHoldingButtons.add(newButton);
}
合金:
function createButtonPress(){
// Store information about new button created somewhere so that it
// shows up the next time the application is run.
// Create the button.
var newButton = Ti.UI.createButton({
title: nameFromTextField.value
color: colorFromTextField.value
});
newButton.addEventListener('click', function(){
// Thing you want the new button to do when pressed.
});
$.viewHoldingButtons.add(newButton);
}
+0
你是我的英雄 2014-10-04 03:16:29
你尝试过什么到目前为止,你可以分享?任何代码? – 2014-10-02 23:58:49