📺 "One project. One language. Three apps." Learn more in our upcoming code sharing webinar!

NativeScript Core

Multi Line

Multi line items

<ListView class="list-group" [items]="countries" (itemTap)="onItemTapFirstList($event)" separatorColor="white">
    <ng-template let-country="item">
        <StackLayout class="list-group-item">
            <Label [text]="country.name" class="list-group-item-heading"></Label>
            <Label [text]="country.desc" class="list-group-item-text" textWrap="true"></Label>
        </StackLayout>
    </ng-template>
</ListView>

Multi line items with separators

<ListView class="list-group" [items]="countries" (itemTap)="onItemTapSecondList($event)" separatorColor="gray">
    <ng-template let-country="item">
        <StackLayout class="list-group-item">
            <Label [text]="country.name" class="list-group-item-heading"></Label>
            <Label [text]="country.desc" class="list-group-item-text" textWrap="true"></Label>
        </StackLayout>
    </ng-template>
</ListView>

Multi line items with thumbnails

<ListView class="list-group" [items]="countries" (itemTap)="onItemTapThirdList($event)" (setupItemView)="onSetupItemView($event)">
    <ng-template let-country="item" let-third="third">
        <GridLayout class="list-group-item" rows="*" columns="auto, *">
            <Image col="0" [src]="country.imageSrc" class="thumb img-circle"></Image>
            <StackLayout col="1">
                <Label [text]="country.name" class="list-group-item-heading"></Label>
                <Label [text]="country.desc" class="list-group-item-text" textWrap="true"></Label>
            </StackLayout>
        </GridLayout>
    </ng-template>
</ListView>

Initializing the data Items

@Component({
    moduleId: module.id,
    templateUrl: "./multi-line.component.html",
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class MultiLineListViewExampleComponent implements OnInit {
    public countries: Array<Country> = [];

    ngOnInit() {
        for (let i = 0; i < mockedDataArray.length; i++) {
            this.countries.push(mockedDataArray[i]);
        }
    }

    onItemTapFirstList(args: ItemEventData) {
        console.log(args.index);
    }

    onItemTapSecondList(args: ItemEventData) {
        console.log(args.index);
    }

    onItemTapThirdList(args: ItemEventData) {
        console.log(args.index);
    }

    onSetupItemView(args: SetupItemViewArgs) {
        // further customisation can be achived with SetupItemViewArgs
        // example for creating a variable for each third element
        args.view.context.third = (args.index % 3 === 0);
    }
}