Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Label text is not updating in tableview children in titanium android.but work's in IOS

$
0
0
I have created a tableview row.here the tableview each row having the one lebel and 2 image view. if am clicking the image, the selected row of label value need to change something. But from my code if am clicking the image, the label value is changed of last item. What's wrong in my code. for( var i=0; i<data.length; i++){ var row = Ti.UI.createTableViewRow({ layout : 'horizontal', width: "100%", height: Ti.UI.SIZE, }); row.add(Ti.UI.createImageView({ image: data[i].image, top: 5, width: '50', height: Ti.UI.SIZE, })); row.add(Ti.UI.createLabel({ text: data[i].name, top: 5, width: 180, color: '#040404', height: Ti.UI.SIZE, })); var deleteitem = Ti.UI.createImageView({ image: "images/back.png", top: 5, i:i, squantity : data[i].itemCount, spprice :data[i].itemPrice, width: Ti.UI.SIZE, height: Ti.UI.SIZE, myrow: row, }); row.add(deleteitem); var adddeleteitemview = Ti.UI.createView({ width: Ti.UI.SIZE, height: Ti.UI.SIZE, layout : 'horizontal', left:10, borderColor:"gray", borderRadius:"10" }); var removeitem = Ti.UI.createImageView({ image: "images/minus.jpg", top: 5, width: Ti.UI.SIZE, squantity : data[i].itemCount, spprice :data[i].itemPrice, height: Ti.UI.SIZE, }); adddeleteitemview.add(removeitem); var itemcounttext = Ti.UI.createLabel({ top: 5, text:data[i].itemCount, width: Ti.UI.SIZE, height: Ti.UI.SIZE, }); adddeleteitemview.add(itemcounttext); removeitem.addEventListener('click', function(e) { var item=e.source.getParent(); squantity = e.source.squantity; spprice = e.source.spprice; totalqty = Number(totalqty) - Number(1); $.ViewCartItemslist_header_cart.text = totalqty; totalamount = Number(totalamount) - Number((spprice)); squantity = Number(squantity) - 1; item.children[1].text = squantity; $.ViewCartItemslist_total_value.text = totalamount; }); var additem = Ti.UI.createImageView({ image: "images/plus.jpg", top: 5, width: Ti.UI.SIZE, squantity : data[i].itemCount, spprice :data[i].itemPrice, height: Ti.UI.SIZE, }); adddeleteitemview.add(additem); additem.addEventListener('click', function(e) { var item=e.source.getParent(); squantity = e.source.squantity; spprice = e.source.spprice; totalqty = Number(totalqty) + Number(1); $.ViewCartItemslist_header_cart.text = totalqty; totalamount = Number(totalamount) + Number((spprice)); squantity = Number(squantity) + 1; item.children[1].text = squantity; $.ViewCartItemslist_total_value.text = totalamount; }); row.add(adddeleteitemview); dataArray.push(row); row.addEventListener('click', function() {}); deleteitem.addEventListener('click', function(e) { squantity = e.source.squantity; spprice = e.source.spprice; $.ViewCartItemstableView.deleteRow(e.source.myrow); totalqty = Number(totalqty) - Number(squantity); $.ViewCartItemslist_header_cart.text = totalqty; totalamount = Number(totalamount) - Number((spprice * squantity)); $.ViewCartItemslist_total_value.text = totalamount; }); }; $.ViewCartItemstableView.setData(dataArray); } It's working well in the IOS.But it's not work with the android implementation. alert(item.children[1].getText()); Here am getting the alert with correct updated value.But it's not showing in the label. Can you give me a idea to resolve this problem in android.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>