Skip to content

Instantly share code, notes, and snippets.

@Velan
Created Jun 29, 2015
Embed
What would you like to do?
var Window = Ti.UI.createWindow();
var WrapperView = Ti.UI.createView();
var ListView = Ti.UI.createListView({
top: 0,
left: 0,
defaultItemTemplate: 'test',
templates: {
test: {
properties: {
height: 100,
backgroundColor: '#ccc'
},
childTemplates: [{
type: 'Ti.UI.Button',
bindId: 'button',
properties: {},
events: {
click: function(e) {
console.log('Click ', {x: e.x, y: e.y});
console.log('Button title', e.source.getTitle());
var point = e.source.convertPointToView({x: Math.round(e.x), y: Math.round(e.y)}, Window);
console.log('Converted', {x: point.x, y: point.y});
}
}
}]
}
}
});
var ListSection = Ti.UI.createListSection();
ListSection.setItems([
{button: {title: 'button 1'}},
{button: {title: 'button 2'}},
{button: {title: 'button 3'}},
{button: {title: 'button 4'}},
{button: {title: 'button 5'}},
{button: {title: 'button 6'}},
{button: {title: 'button 7'}},
{button: {title: 'button 8'}},
{button: {title: 'button 9'}}
]);
ListView.setSections([ListSection]);
WrapperView.add(ListView);
Window.add(WrapperView);
Window.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment