Search code examples
titaniumappceleratorappcelerator-mobile

Titanium: How to to display text and images together inline in a tableview?


What I have is an XML feed of data that are basicly like facebook wall posts.

The posts themselves contain text with interspersed images and video links. Now I can parse (using regex) all the links without a problem.

MY question is what is the best way to display this to the user?

Right now I created a tableview and have each row in the table view display a post. It looks great but the images dont display, they are just raw links to an image URL.

Someone suggested to try a webview, and I placed the webview inside of the tableviewrow, but im getting mixed results as for some reason all the webviews (about 20 tableviewrows/webviews) overrun and overlap each other.

Is there a better strategy to display this data in an organized top down way?

Thanks!!


Solution

  • i would extract the content of the xml as follows:

    post = this.responseXML;
    feed = {
     picture: post.getElementsByTag('TagNameOfImage'),
     text: post.getElementsByTag('TagNameOfText')
    };
    

    then i would use a label for the text

    var label = Ti.UI.createLabel({
      text: feed.text
    });
    
    yourRow.add(label);
    

    and a imageView for the picture:

    var iv = Ti.UI.createImageView({
      image: feed.picture
    });
    
    yourRow.add(iv);
    

    hope i could help you.