我是学生,所以很抱歉问了这么简单的问题。我正在尝试制作一个“下一个”和“上一个”按钮,一次循环一个数组。
var food = ["pasta", "Salad", "Apple", "Pizza"];
counter=0;
var displayAlert = function(){
for (var i=0, item; i<food.length; i++) {
item = food[i];
quoteText.text=food[i];
}
};
var quoteView = Ti.UI.createView({
backgroundColor: "#fff",
height: 150,
top: 50,
left: 20,
right: 20,
borderRadius: 5
});
var quoteText = Ti.UI.createLabel({
text: "click below to begin",
font: {fontSize: 20, fontFamily: "Arial"},
textAlign: "center"
});
quoteView.add(quoteText);
mainWindow.add(quoteView);
buttonPrevious.addEventListener("click", displayAlert);
buttonNext.addEventListener("click", displayAlert);