I am trying to build a Contacts List type POC for NativeScript. And I would like to have an image and name in a list item. The code that I am using for the layout is as follows
<Page loaded="pageLoaded">
<ListView items="{{ myItems }}">
<ListView.itemTemplate>
<Image src="{{ imageSrc }}" />
<Label text="{{ title }}" />
</ListView.itemTemplate>
</ListView>
</Page>
Apparently, the title value is coming up fine, but the image is not showing up at all. When I try to put the same Image code in an empty page, NativeScript builds the page with image.
Can anyone tell me why the image is not coming up in the listview template? And how can it be displayed?
Thanks
I tested this; You need to put the inner items in a layout. I believe the itemTemplate can only be ONE child. All my tests seem to indicate that itemTemplate points to a single child.
So this works fine as the single child is a StackLayout which then contains your two items.
XML:
For code completion (for anyone looking at this in the future) the simplest JS: