Titanium 在一行中添加一个swtich,并在两个上都被点击。

Titanium 在一行中添加一个swtich,并在两个上都被点击。,titanium,titanium-alloy,Titanium,Titanium Alloy,我用钛合金创建了一个tableView,并在其中添加了一行和一个开关。我面临的问题是,当我点击开关行时,也会被点击。我怎样才能阻止这一切?有没有办法停下来。我读过几个链接,其中他们说在视图中添加开关,然后在第行中添加该视图,但这不起作用。下面是代码 <Alloy> <Window class="container"> <TableView width="100%" height="60%" top="5"> &l

我用钛合金创建了一个tableView,并在其中添加了一行和一个开关。我面临的问题是,当我点击开关行时,也会被点击。我怎样才能阻止这一切?有没有办法停下来。我读过几个链接,其中他们说在视图中添加开关,然后在第行中添加该视图,但这不起作用。下面是代码

<Alloy>
    <Window class="container">
        <TableView width="100%" height="60%" top="5">
            <TableViewRow height="50" onClick="dont" width="100%" backgroundColor=" yellow">
                <View width= "100%" height="100%" onClick="doNothing">
                    <Switch value="On" top="5" right="5" onClick="doNot"></Switch>
                </View>
            </TableViewRow>
        </TableView>
    </Window>
</Alloy>
当我点击开关时,两个函数都被调用。。。
钛合金版本:3.4.1 GA

您应该如何操作: 在tableView上添加onClick listener,在交换机上添加onChange listener:

<Alloy>
   <Window class="container">
     <TableView width="100%" height="60%" top="5" onClick="dont">
        <TableViewRow height="50"  width="100%" backgroundColor=" yellow">
            <View width= "100%" height="100%">
                <Switch value="On" top="5" right="5" onChange="doSwitchChange"></Switch>
            </View>
        </TableViewRow>
    </TableView>
  </Window>
</Alloy>
function dont(e) {
    if (e.source == e.row.children[0])
        Ti.API.debug('the View');
    else
        Ti.API.debug('the Switch');
}

function doSwitchChange(e) {
        Ti.API.debug(e.value);
}