I am following a multiple spectrum course, and I have run into an odd problem. In my list view, only the first item is displayed and nothing else. This is odd, and I used listviews without problems before I’m not sure where the error is coming from.
Layout:
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
loaded="pageLoaded">
<GridLayout rows="auto, *">
<StackLayout cssClass="page-header">
<Label text="Header" cssClass="page-title bold" horizontalAlignment="center" margin="15"/>
</StackLayout>
<GridLayout rows="auto, *" row="1">
<ListView items="{{ sessions }}">
<ListView.itemTemplate>
<Label text="{{ title }}"/>
</ListView.itemTemplate>
</ListView>
</GridLayout>
</GridLayout>
</Page>
Typescript:
import { EventData, Observable } from "data/observable";
import { Page } from "ui/page";
var page: Page;
var tempSessions = [
{
id: '0',
title: "Stuff"
},
{
id: '1',
title: "Stuffly"
},
{
id: '2',
title: "Stufferrs"
},
{
id: '3',
title: "Event 4"
}
];
export function pageLoaded(args: EventData){
console.log(JSON.stringify(tempSessions));
page = <Page>args.object;
page.bindingContext = new Observable({
sessions: tempSessions
});
}
I suspected that the first element of the list completely fills the gridLayout, however placing the border around it shows that this is not the case.
source
share