Skip to content

Instantly share code, notes, and snippets.

@taazza

taazza/AppendRow Secret

Created February 18, 2011 09:59
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 taazza/4c226b378d20ec7f76ef to your computer and use it in GitHub Desktop.
Save taazza/4c226b378d20ec7f76ef to your computer and use it in GitHub Desktop.
Titanium Scroll issue with AppendRow
// create table view
var tableview = Titanium.UI.createTableView();
Ti.App.fireEvent("show_indicator");
// create table view event listener
tableview.addEventListener('click', function(e)
{
// event data
var index = e.index;
var section = e.section;
var row = e.row;
var rowdata = e.rowData;
Titanium.UI.createAlertDialog({title:'Table View',message:'row ' + row + ' index ' + index + ' section ' + section + ' row data ' + rowdata}).show();
});
var navActInd = Titanium.UI.createActivityIndicator();
navActInd.show();
if (Titanium.Platform.name == 'iPhone OS') {
Titanium.UI.currentWindow.setRightNavButton(navActInd);
}
// add table view to the window
Titanium.UI.currentWindow.add(tableview);
Titanium.Yahoo.yql('select * from flickr.photos.search where text="Dog" limit 25',function(e)
{
var images = [];
var data = e.data;
navActInd.hide();
Ti.App.fireEvent("hide_indicator");
for (var c=0;c<data.photo.length;c++)
{
var photo = data.photo[c];
// form the flickr url
var url = 'http://farm' + photo.farm + '.static.flickr.com/' + photo.server + '/' + photo.id + '_' + photo.secret + '_m.jpg';
Ti.API.info("flickr url = "+url);
var row = Ti.UI.createTableViewRow({height:60});
var title = Ti.UI.createLabel({
left:70,
right:10,
textAlign:'left',
height:50,
text:photo.title ? photo.title : "Untitled",
font:{fontWeight:'bold',fontSize:18}
});
var image;
if (Titanium.Platform.name == 'android')
{
// iphone moved to a single image property - android needs to do the same
image = Ti.UI.createImageView({
url : url,
height:50,
width:50,
left:10,
defaultImage:'../modules/ui/images/photoDefault.png'
});
}
else
{
image = Ti.UI.createImageView({
image : url,
height:50,
width:50,
left:10,
defaultImage:'../modules/ui/images/photoDefault.png'
});
}
row.add(image);
row.add(title);
tableview.appendRow(row);
// images[c] = row;
}
// tableview.setData(images);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment