Javascript 如何通过在钛Appcelerator中按下另一个按钮来创建一个按钮?
我的问题措辞很糟糕,对不起 所以我想做的是进入createNewCourseScreen,输入名称并设置颜色,然后按下create按钮,创建的按钮将在CourseScreen的其他按钮下弹出 我是一个钛合金巨人,需要你的帮助 屏幕 课程屏幕:Javascript 如何通过在钛Appcelerator中按下另一个按钮来创建一个按钮?,javascript,titanium,appcelerator,Javascript,Titanium,Appcelerator,我的问题措辞很糟糕,对不起 所以我想做的是进入createNewCourseScreen,输入名称并设置颜色,然后按下create按钮,创建的按钮将在CourseScreen的其他按钮下弹出 我是一个钛合金巨人,需要你的帮助 屏幕 课程屏幕: newCourseScreen:你可能把这个问题的思考过程复杂化了。也许你使用的是合金,这是不太直接看到如何实现这一点。在classic Titanium中,您已经有了显示如何创建按钮和事件侦听器的代码 一般步骤: 1-获取标题和颜色的输入。 2-调用on
newCourseScreen:你可能把这个问题的思考过程复杂化了。也许你使用的是合金,这是不太直接看到如何实现这一点。在classic 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);
}
到目前为止你试过什么吗?你能分享一些代码吗?