Hi,
I wonder if someone could show me basic code how to make a clickable row to show information in the window. For example.
Parties (Header) - Jennas party -> Time: 18.00 Street adress: Blabla 18 Info: (Some long text) - Henriks party -> Time: 19.00 Street adress: Blabla 14 Info: (Some long text)
Etc.
This is my simple code today that i have used from the tutorials.
var currentWin = Titanium.UI.currentWindow; var sectionFruit = Ti.UI.createTableViewSection({ headerTitle: 'Kommande resor' }); sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' })); sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' })); var sectionVeg = Ti.UI.createTableViewSection({ headerTitle: 'Äldre resor' }); sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots', })); sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' })); var table = Ti.UI.createTableView({ data: [sectionFruit, sectionVeg] }); currentWin.add(table);
Thanks in forward :)
2 Answers
Accepted Answer
You listen for the click event on the table, and use the row to build out a detail window. ie:
var win = Titanium.UI.createWindow({backgroundColor:'#fff'}); var sectionFruit = Ti.UI.createTableViewSection({ headerTitle: 'Kommande resor' }); sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' })); sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' })); var sectionVeg = Ti.UI.createTableViewSection({ headerTitle: 'Äldre resor' }); sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots', })); sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' })); var table = Ti.UI.createTableView({ data: [sectionFruit, sectionVeg] }); table.addEventListener('click', function(e) { var detailsWin = Ti.UI.createWindow({ backgroundColor:'#dfdfdf' }); var lbl = Ti.UI.createLabel({ text:e.source.title }); lbl.addEventListener('click', function() { detailsWin.close(); }); detailsWin.add(lbl); detailsWin.open(); }); win.add(table); win.open();
Hi!
Thank you it works flawless! But when i go back on my android device the program exits/quits, what type of code do you attach so you just get backward one step and not close the app after viewing a row with info?
Thanks in forward :)
Your Answer
Think you can help? Login to answer this question!