Listviews with images and text

2 posts, 0 answers
  1. assis
    assis avatar
    2 posts
    Member since:
    May 2015

    Posted 18 May 2015 Link to this post

    <ListView items="{{ menu }}" row="1" itemTap="listViewItemTap" >
          <ListView.itemTemplate>
            <GridLayout columns="auto, *">
              {%raw%}<Image src="{{ imageURL }}" row="0" cssClass="icon"/>{%endraw%}
              <StackLayout col="1">
                <Label text="{{ title || 'Downloading...'}}"  cssClass="name"/>
                <Label text="{{ subtitle }}" cssClass="location"/>
              </StackLayout>
            </GridLayout>
          </ListView.itemTemplate>
     </ListView>

    I have this xml file, I want to get a list with a image and a title and subtitle.

    in the javascript I have

        for (var i = 0; i < list.length; i++)
        {
            menu.push({
               imageURL : images.imageURL(list[i].icon),
                title: list[i].menu,
                subtitle: list[i].desc
            })
        }

     

    where imageURL is:

    imageSource.fromUrl(server.address + '/' + path)
                              .then(function (res) {
                                  console.log("Image successfully loaded");
                                  return res;
                              }, function (error) {
                                  console.log("Error loading image: " + error);
                              });

     

    But I can't see the image, I try all, change in the xml the 'src' to 'url' or to 'source' and nothing.

    what I did wrong, can anyone help me?

  2. assis
    assis avatar
    2 posts
    Member since:
    May 2015

    Posted 18 May 2015 in reply to assis Link to this post

    I see the error, the array was creater before the image was loaded, now is working.
Back to Top