0

我有两个选项卡布局。单击第一个选项卡按钮时,使用远程检索的数据填充行。这与第二个选项卡相同,但数据的布局不同。

我的问题是,当您在选项卡之间切换时,我需要在每个选项卡的第一行触发点击事件。

我正在为 android 构建这个应用程序。

任何帮助是极大的赞赏...

编辑:这是头顶的虚拟代码,希望它更有意义。

leftTableView = Ti.UI.createTableView({
  data: populateTableView(0),
  allowsSelection:true
}); 

function populateTableView(byType)
{
for(length of array loop){
    var tableViewRow=Ti.UI.createTableViewRow({
        my_obj:myObj[i]
    });

    tabledata=[]

    tableViewRow.addEventListener('click',function(e){
        e.row.setBackgroundImage('/images/selected-row-background.png');
    }

    if byType 0

        loop array display row for each object element
        tableData.push(tableViewRow);   
        return tabledata


    if byType 1

        loop array display row for each object element, display differently
        tableData.push(tableViewRow);   
        return tabledata
}
}

tab 1 click event listener

populateTableView(0);
leftTableView.data[0].rows[0].fireEvent('click');//this fires but says e.row.setBackgroundImage is undefined

tab 2 click event listener

populateTableView(1)
leftTableView.data[0].rows[0].fireEvent('click');//this fires but says e.row.setBackgroundImage is undefined
4

1 回答 1

1

监听 tabGroup 上的 blur 事件,并在每个选项卡成为活动选项卡时采取行动

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TabGroup-event-blur

tabGroup.addEventListener('blur', function(_event) {
    var activeTab = _event.tab;

    // now that you have the activeTab, get the window, then the 
    // table and call a method to simulate a click on the first
    // row
});

触发事件时传递数据

var row = leftTableView.data[0].rows[0];
row.fireEvent('click', { row : row } )
于 2013-06-28T11:43:40.310 回答