有谁知道这是怎么做到的吗?我有这个代码:

var txtOne = Titanium.UI.createTextField({
    top:50,
    zIndex:1
});

var txtTwo = Titanium.UI.createTextField({
    top:100
});

var txtThree = Titanium.UI.createTextField({
    top:150,
    zIndex:2
});


我只想从txtOne跳到txtThree而无需转到txtTwo。

我尝试使用zIndex,但不适用于我。

任何的想法??谢谢

最佳答案

您可以将它们放入数组中,并为它们的返回函数分配事件处理程序,如下所示:

var textFields = [txtOne, txtTwo, txtThree];

for(vat i=0; i < textFields.length; i++)
{
    //make the last text field jump to the first one when returning
    if(i == textFields.length-1)
    {
        textFields [i].addEventListener('return', function(e)
        {
            textFields[0].focus();
        });
    }
    else
    {
        //jump to the next text fields when returning
        textFields [i].addEventListener('return', function(e)
        {
            textFields[i+1].focus();
        });
    }
}

10-07 17:14