Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-17045

Android: Label 'html' and 'text' properties don't work together in ListView

    Details

    • Sprint:
      2014 Sprint 11 SDK

      Description

      Due to listView architecture of view recycling, 'html' and 'text' don't work together in side a list view.

      var self = Ti.UI.createWindow({
          backgroundColor: 'white'
      });
      var myTemplate = {
          childTemplates: [                   // 
              {                            // Title 
                  type: 'Ti.UI.Label',     // Use a label for the title 
                  bindId: 'info',          // Maps to a custom info property of the item data
                  properties: {            // Sets the label properties
                      color: 'black',
                      font: { fontFamily:'Arial', fontSize: '20dp', fontWeight:'bold' },
                      left: '60dp', top: 0,
                      autoLink: Ti.UI.AUTOLINK_ALL
                  }
              },
              {                            // Subtitle
                  type: 'Ti.UI.Label',     // Use a label for the subtitle
                  bindId: 'es_info',       // Maps to a custom es_info property of the item data
                  properties: {            // Sets the label properties
                      color: 'gray',
                      font: { fontFamily:'Arial', fontSize: '14dp' },
                      left: '60dp', top: '50dp',
                      autoLink: Ti.UI.AUTOLINK_NONE
                  }
              }
          ]
      };
         
      var listView = Ti.UI.createListView({
          // Maps myTemplate dictionary to 'template' string
          templates: { 'template': myTemplate },
          // Use 'template', that is, the myTemplate dict created earlier
          // for all items as long as the template property is not defined for an item.
          defaultItemTemplate: 'template'
      });
      var sections = [];
         
      var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits / Frutas'});
      var fruitDataSet = [
          { info: {html: "<a href='http://google.com'>http://google.com</a>"}, es_info: {text: 'Manzana'}},
          { info: {text: "Banana\t http://en.wikipedia.org/wiki/Banana"}, es_info: {text: 'Banana'}},
          { info: {text: "Pineapple\t http://en.wikipedia.org/wiki/Pineapple"}, es_info: {text: 'Pina'}},
          { info: {text: "Peach \thttp://en.wikipedia.org/wiki/Peach"}, es_info: {text: 'Durazno'}},
          { info: {text: "Apple\t http://en.wikipedia.org/wiki/Apple"}, es_info: {text: 'Manzana'}},
          { info: {text: "Banana\t http://en.wikipedia.org/wiki/Banana"}, es_info: {text: 'Banana'}},
          { info: {text: "Pineapple\t http://en.wikipedia.org/wiki/Pineapple"}, es_info: {text: 'Pina'}},
          { info: {text: "Peach \thttp://en.wikipedia.org/wiki/Peach"}, es_info: {text: 'Durazno'}}
      ];
      fruitSection.setItems(fruitDataSet);
      sections.push(fruitSection);
         
      var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables / Verduras'});
      var vegDataSet = [
          { info: {text: 'Carrot\thttp://en.wikipedia.org/wiki/Carrot'}, es_info: {text: 'Zanahoria'}},
          { info: {text: 'Potato\thttp://en.wikipedia.org/wiki/Potato'}, es_info: {text: 'Patata'}},
          { info: {text: 'Carrot\thttp://en.wikipedia.org/wiki/Carrot'}, es_info: {text: 'Zanahoria'}},
          { info: {text: 'Potato\thttp://en.wikipedia.org/wiki/Potato'}, es_info: {text: 'Patata'}},
      ];
      vegSection.setItems(vegDataSet);
      sections.push(vegSection);
         
      var grainSection = Ti.UI.createListSection({ headerTitle: 'Grains / Granos'});
      var grainDataSet = [
          { info: {text: "Corn\t http://en.wikipedia.org/wiki/Maiz"}, es_info: {text: 'Maiz'}},
          { info: {text: "Rice\t http://en.wikipedia.org/wiki/Rice"}, es_info: {text: 'Arroz'}},
          { info: {text: "Wheat\t http://en.wikipedia.org/wiki/Wheat"}, es_info: {text: 'Trigo'}},
          { info: {text: "Corn\t http://en.wikipedia.org/wiki/Maiz"}, es_info: {text: 'Maiz'}},
          { info: {text: "Rice\t http://en.wikipedia.org/wiki/Rice"}, es_info: {text: 'Arroz'}},
          { info: {text: "Wheat\t http://en.wikipedia.org/wiki/Wheat"}, es_info: {text: 'Trigo'}}
      ];
      grainSection.setItems(grainDataSet);
      sections.push(grainSection);
         
      listView.setSections(sections);
             
      self.add(listView);
      self.open();
      

      Steps to reproduce:
      1. Run code above
      2. Notice missing rows (you may need to scroll back and forth, depending on device)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hpham Hieu Pham
                Reporter:
                hpham Hieu Pham
                Reviewer:
                Vishal Duggal (Inactive)
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-18766
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration