Abli
Abli

Reputation: 1

How to display images from my API JSON array?

How can I display images from a JSON sub-array which is received via my API? I can display the title, the price and the description but not the actual image. Can anyone give me a tip?

My XML: Screenshot of my xml

My JSON structure: Screenshot of my JSON structure

Upvotes: 0

Views: 812

Answers (2)

Fokke Zandbergen
Fokke Zandbergen

Reputation: 3866

If you just need to display one image, use a dataTransform attribute where you also have the dataCollection attribute (see https://appcelerator.github.io/appc-docs/latest/#!/guide/Alloy_Data_Binding-section-36739592_AlloyDataBinding-Collection-ViewBinding) to select/compose the image URI from the JSON and then use the property in <ImageView image="{myImage}" />

Upvotes: 1

miga
miga

Reputation: 4055

You need to loop through the image array and create the ImageView inside JS. To display the images you can use a ScrollableView (http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ScrollableView) and add the images as a view.

Upvotes: 0

Related Questions