variable or index on dynamic imageView? detect when clicked!
trying to dynamically display thumbnails of images and when clicked, it will bring up a new window showing the full size image.
and this is where the problem lies. how do i detect which imageView ( or regular view ) was clicked? i can't figure out a way to detect that imageView #4 is being clicked instead of imageView #2 and so on.
any help would be greatly appreciated!
rocksteady,
danno~
3 Answers
-
First assign an id/index to that imageview on the list, then use on click event to retrieve the source id/index.
images.addEventListener('singletap', function(e) { var s = e.source; alert(s.id) //this is the id or whatever index or url of the image you can recall from singletap event. })
-
yeah, that's my question, how do i add an id to the imageView?
thanks!
rocksteady,
danno~ -
and i answered my own question:
var imageView = Titanium.UI.createView({ backgroundImage:'image.jpg', height:50, width:50, top:10, left:10, borderWidth:3, id:'thisIsMyID', borderColor:'#fff' });
and to recover that variable, like you said , it's :
images.addEventListener('singletap', function(e) { var s = e.source; alert(s.id) })
thanks for the help, i appreciate it!
rocksteady,
danno~