0

考虑一个展开和折叠的视图,一次可见,在点击事件上切换。

在 TableRowView 中,我可以设置 TableViewRow 的高度并在展开视图和折叠视图之间切换。视图显示,但 TSS 样式丢失 - 例如,背景颜色。

这是一个示例合金项目,演示:

索引.xml:

        <TableView>

            <TableViewRow id="row">

                <View id="staticSection">
                    <Label>static section</Label>
                </View>

                <View id="collapsedView" onClick="expand">
                    <Label>collapsed</Label>
                </View>

                <View id="expandedView" onClick="collapse">
                    <Label>expanded</Label>
                </View>

                <View id="staticRuler">
                </View>

            </TableViewRow>

            <TableViewRow>
                <Label>next row</Label>         
            </TableViewRow>

        </TableView>

    </Window>
</Alloy>

索引.tss:

".container": {
    backgroundColor:"white"
},

"TableView": {
    separatorColor: 'transparent'
}


"#row": {
    layout: 'vertical'
}

"#staticSection": {
    height: 25
}


"#collapsedView": {
    height: 50,
    backgroundColor: '#dfd'
}

"#expandedView": {
    height: 100,
    backgroundColor: '#fdd'
}

"#staticRuler": {
    width: Ti.UI.FILL,
    height: 5,
    backgroundColor: '#666'
}

index.js:

$.index.open();

function expand() {
    $.expandedView.visible = true;
    $.collapsedView.visible = false;
    $.row.height = 130;
}

function collapse() {
    $.expandedView.visible = false;
    $.collapsedView.visible = true;
    $.row.height = 80;
}

collapse();

如何构建可以数据绑定到合金集合并保持其样式的展开/折叠视图?如果 ScrollView 或其他一些非 TableView 元素更适合这个(ListView?),你能演示一个工作示例吗?

4

1 回答 1

0

通过使用此行样式调整大小时,我已经能够保留样式:

TableViewRow: {
    selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
}
于 2013-08-09T19:10:10.593 回答