Skip to content

Instantly share code, notes, and snippets.

@Velan
Created June 29, 2015 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Velan/f3d75612a611b9a47568 to your computer and use it in GitHub Desktop.
Save Velan/f3d75612a611b9a47568 to your computer and use it in GitHub Desktop.
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