在我的NativeScript App中有一个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;
}
答案 0 :(得分:1)
您正在使用ListView,因此您需要为该Image标记提供静态高度和宽度...
<Image ind="{{ ind }}" tap="removeIncomeElement" src="~/img/ic_close/png" col="2" width="75" height="75" />