Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Encouragement of ListView

Encouragement of ListView

Introduction of Titanium 3.1 ListView

Avatar for Ryutaro Miyashita

Ryutaro Miyashita

July 14, 2013
Tweet

More Decks by Ryutaro Miyashita

Other Decks in Technology

Transcript

  1. var plain_template = { childTemplates: [{ type: "Ti.UI.Label", bindId: "myLabel",

    properties: { left: "10dp" }, events: { click: reportFunction } }] }; var list = Ti.UI.createListView({ templates: { plain: plain_template }, defaultItemTemplate: "plain" }); 5JUBOJVN΋͘΋͘ձJO/*'5: ςϯϓϨʔτͷઃఆ
  2. var data = []; [1,2,3,4,5].forEach(function (idx) { data.push({ myLabel: {

    text: "Row #" + idx }, properties: { itemId: "item" + idx } }); }); var section = Ti.UI.createListSection({ items: data }); list.sections = [section]; 5JUBOJVN΋͘΋͘ձJO/*'5: ςϯϓϨʔτΛ࢖ͬͯΞΠςϜΛ࡞Δ
  3. 5JUBOJVN΋͘΋͘ձJO/*'5: list.addEventListener( "itemclick", function (e) { // Get clicked item

    reference var item = e.section.getItemAt(e.itemIndex); console.log(item.properties.itemId); // Replace clicked item e.section.UpdateItemAt(e.itemIndex, item); } ); -JTU7JFXͷΠϕϯτϋϯυϦϯά
  4. -JTU7JFX 5BCMF7JFX ˚ "OESPJE   Y J1IPOF 4JNVMBUPS 

     Y J1IPOF   Y ୯Ґ<NT> 5JUBOJVN΋͘΋͘ձJO/*'5: