Hi All ,
I want to add children (N number of Labels) into ListView's custom templates children view at the time of Network call success,
I will come to know the count of Labels after the web service call response only, So i want to create/add labels on that place, But its seems to we can't do it Since the children views are read only. Please let me know if there is any solution?
Reason for the need:
Assume the description is posted by user along with image,
I am at #Chennai with @Simbu, @Raj
Here i need to display the # word with Blue color, @word with Pink color, and clicking on #word will takes to search page, @name will takes to that persons profile page, Like Instagram app.
var myTemplate = { properties : { height : Ti.UI.SIZE, selectedBackgroundColor : "transparent", backgroundColor : "transparent", selectionStyle : Ti.Platform.osname == 'android' ? '' : Ti.UI.iPhone.ListViewCellSelectionStyle.NONE }, childTemplates : [// Outer child Start { type : 'Ti.UI.View', bindId : 'leftside', properties : { width : 320, height : Ti.UI.SIZE, left : 0, right : 0, top :0, backgroundColor : '#fff' }, childTemplates : [// inner childtemplate start { type : 'Ti.UI.ImageView', bindId : 'pic1', properties : { width : 320, height : 320, top : 20 } },{ type : 'Ti.UI.View', bindId : 'aboutView', properties : { borderColor : "#000", top : 325, height : 120, width : 310, layout : "horizontal", left : 10, right :2 },childTemplates : [] }] }] }; function LabelChild(desc){ var arrayChild =[]; var desctemp = desc; if(desctemp) { var tagslistarr = desctemp.split(' '); function DescSet(bid, txt){ var descLbl = { type : 'Ti.UI.Label', bindId : bid, properties : { top : globalVariables.GetHeight(0), left : globalVariables.GetWidth(0), ellipsize : false, layout : 'horizontal', height : globalVariables.GetWidth(15), font : { fontSize : globalVariables.GetWidth(11), fontFamily : VARS.globalfont_family }, text : txt, backgroundColor : VARS.blueColor, color : VARS.blackColor } }; Ti.API.info(descLbl); return descLbl; } for (var i in tagslistarr) { DescSet('SepDescText'+i, tagslistarr[i]); } } Ti.API.info(arrayChild); return arrayChild; } // ################## Description Management ################### // ##############ListView ############### var listView = Ti.UI.createListView({ templates : { 'template' : myTemplate }, defaultItemTemplate : 'template', backgroundColor : "#FFF", separatorColor : "#CCC", top : 30, width : 320 }); ############# WEB SERVICE CALL ##########// function genData(i) { var sectionData = []; var updateView = function(status, locationHeader, data) { var remdata = data; for (var i = 0; i < remdata.length; i++) { sectionData.push({ leftside : { ProjID : remdata[i].attachid, SellerID : remdata[i].user_id }, pic1 : { image : remdata[i].filename }, aboutView : { LabelChild(remdata[i].description) }, properties : { sellerid : remdata[i].user_id, itemId : 'row1', accessoryType : Ti.UI.LIST_ACCESSORY_TYPE_NONE }, });
Application type: mobile
Titanium SDK: 3.5.0.GA
3.Platform & version: iOS x.x, Android x.x,
Device: iOS simulator, Android emulator and iPhone 4S
Host Operating System: OSX 10.9.5
Titanium Studio: 3.4.1