在我的 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;
}