If I add native checkbox, row click stops working and works only on labels. The empty areas in row not work on click. Here is the code:
var paidSwitch = Titanium.UI.createSwitch({ top:5, left:0, width:50, style:Titanium.UI.Android.SWITCH_STYLE_CHECKBOX, arrow: true, touchEnabled:true, value:false, }); var paidCheckbox = Titanium.UI.createImageView({ image:'../images/unchecked.png', width:20, height:30, top:0, left:0, arrow: false, visible: false }); var label = Ti.UI.createLabel({ text:title, left:40, top:0, arrow: false, touchEnabled:true, font:{fontColor:"#666666",fontSize:14,fontWeight:'bold', fontFamily:'Arial'}, color:'#666666' }); var labeledit = Ti.UI.createLabel({ text:item.getElementsByTagName("ReceiveDate").item(0).text, left:265, textAlign:'center', top:0, arrow: false, touchEnabled:true, font:{fontColor:"#000000",fontSize:13,fontWeight:'bold', fontFamily:'Arial'}, color:'#000000' }); title = item.getElementsByTagName("ShortSubject").item(0).text; var labelstate = Ti.UI.createLabel({ text:title, left:40, arrow: false, touchEnabled:true, top:20, font:{fontColor:"#000000",fontSize:11,fontWeight:'bold', fontFamily:'Arial'}, color:'#000000' }); title = item.getElementsByTagName("ShortBody").item(0).text; var labelbody = Ti.UI.createLabel({ text:title, left:40, top:35, arrow: false, touchEnabled:true, font:{fontColor:"#515151",fontSize:12,fontFamily:'Arial'}, color:'#515151' }); title = item.getElementsByTagName("ID").item(0).text; var lblID = Ti.UI.createLabel({ text:title, left:100, top:0, arrow: false, touchEnabled:true, visible:false, font:{fontColor:"#515151",fontSize:12,fontFamily:'Arial'}, color:'#515151' }); var CheckedCheckbox = Titanium.UI.createImageView({ image:'../images/checked.png', width:20, height:20, top:0, visible:false, left:0 }); row.add(paidSwitch); row.add(paidCheckbox); row.add(label); row.add(labeledit); row.add(labelstate); row.add(labelbody); row.add(lblID); row.add(CheckedCheckbox); if(item.getElementsByTagName("FlagStatus").item(0).text == 0){ row.backgroundColor = '#ffffff'; } else{ row.backgroundColor = '#cccccc'; } data[x++] = row; var tableview = Titanium.UI.createTableView({ data:data, top:40 }); Titanium.UI.currentWindow.add(tableview);
1 Answer
I don't see where you created "row", but you need touchEnabled=false on the labels, and touchEnabled=true on the TableViewRow (if that's what "row" is). Don't specify touchEnabled at all on the Switch.<br>
<br>
Beware that you may find that the switches don't repaint themselves if the parent of the TableView has layout set to 'vertical'. I think this is a TableView bug.
Your Answer
Think you can help? Login to answer this question!