Label text is not updating in tableview children in titanium android.but work's in IOS
Instead of walking the parent/child tree, just make itemcounttext a property of additem:
var itemcounttext = Ti.UI.createLabel({ top: 5, color: "#000000", left:10, text:data[i].itemCount, width: Ti.UI.SIZE, height: Ti.UI.SIZE});var additem = Ti.UI.createImageView({ image: "/images/plus.jpg", top: 5, width: Ti.UI.SIZE, left:10, height: Ti.UI.SIZE,});additem.countTextLabel = itemcounttext;adddeleteitemview.add(additem);additem.addEventListener('click', function(e) { var item=e.source; var squantity = e.source.squantity; squantity = Number(squantity) + 1; item.countTextLabel.setText(squantity); alert(item.countTextLabel.getText());});
I struggled with this for the better part of an afternoon. Hopefully this helps someone.
In my case I had a tableview with just 1 custom row by design. Clicking the row allowed me to choose a new value (name and description) from a different tableview, and then update the first tableview custom row data with the newly selected values.
For the problematic tableview, I was using setData, but the custom rows are fairly complex so I didn't want to have to rebuild one row of one of these complex rows. Here is what worked for me... I just updated the labels in the data array that are contained in a wrapper view that is contained in the row. This way rather than rebuilding all of the data array from scratch, I was able to modify the array and then just set data again. dataStatus[0].children[0].children[0].text = sice.row.name;
dataStatus[0].children[0].children[1].text = sice.row.statusdescription;tableviewStatus.setData(dataStatus);
I only have 1 row so dataStatus[0] addresses that row. Then the first child is the wrapper view, and I counted my layout and the 1st and 2nd child of the wrapper are the labels I needed to update. Then after I modified the array, I just redid setData. Worked like a champ.
Hope it helps someone.