Changing the text in a lable in a view in a table row?
Suppose I have a label created from
var headerView = Ti.UI.createView({
height:'auto'
});
And I also create a view
var headerLabel = Ti.UI.createLabel({
width:'auto',
height:'auto',
text:"test", // Language
});
headerView.add(headerLabel);
And I add create a TableViewSection …
data[0] = Ti.UI.createTableViewSection({
headerView:headerView
});
And a row
var row = Ti.UI.createTableViewRow({
height:'auto'
});
And
data[0].add(row);
// create table view
var tableview = Titanium.UI.createTableView({
data:data,
backgroundColor:'transparent',
style: Titanium.UI.iPhone.TableViewStyle.GROUPED
});
How do I later change the text in the headerview label currently set as 'test'?
3 Answers
-
Accepted Answer
I think this might be what you're after:
tableview.addEventListener('click', function(e) { e.section.headerView.children[0].text = 'New label'; });
There have been some repaint issues with headers though so if you don't see a change you might need to inspect
headerLabel.text
directly to see whether the code worked (and if so patiently wait for a repaint fix). -
or an easier way:
headerLabel.text = "new text";
-
Thanks, it work but there is a repaint issues. Will see if I can find a fix.