3

在我的 NativeScript 应用程序中有一个 ListView。在js中添加新项目并且高度不会改变。ListView如何调整孩子的高度?

XML:

<ListView id="incomeList" items="{{ income }}" row="1" itemTap="">
    <ListView.itemTemplate>
        <StackLayout orientation="horizontal" cssClass="shares-item">
            <GridLayout columns="*, *, auto">
                <TextField text="{{ userId }}" cssClass="shares-item-label" col="0" keyboardType="number" />
                <TextField text="{{ cost }}" cssClass="shares-item-label" col="1" keyboardType="number"/>
                <Image ind="{{ ind }}" tap="removeIncomeElement" src="~/img/ic_close.png" col="2"/>
            </GridLayout>
        </StackLayout>
    </ListView.itemTemplate>
</ListView>

JS:

var incomeItems = new observableArray.ObservableArray();

function pageLoaded(args) {
    page = args.object;
    incomeList = view.getViewById(page, "incomeList");
}

function addIncome(args) {
    newItem = new observable.Observable({userId: 0, cost: 0, summ: 0, ind: incomeIndex});
    incomeItems.push(newItem);
    incomeList.items = incomeItems;
}
4

1 回答 1

1

您正在使用 ListView,因此您需要为该 Image 标签提供静态高度和宽度...

<Image ind="{{ ind }}" tap="removeIncomeElement" src="~/img/ic_close/png" col="2" width="75" height="75" />
于 2016-09-01T20:38:18.210 回答