imageview or button link
Hi
Slowly getting the hang of titanium but cant seem to find an answer for this:
I have a window with four images that I want the user to click on one of the images to go to another view. The Window is not in a tab group just images to navigate between views. I've tried a few event listener options but in the simulator the image (coded as either as a button or just plain imageview) when selected does nothing? any ideas?
3 Answers
-
Something like this should work:
var win = Ti.UI.currentWindow; var imageViewButton = Ti.UI.createImageView({ top:10, width:20, height:20, image:'some_image.png' }); win.add(imageViewButton); imageViewButton.addEventListener('click',function(){ Ti.API.info('you clicked the view! do something now...'); });
-
HI Kosso
Thats fine for creating an alert when clicked but I want it to go to a new view called for example "new.js", its the url bit I need. thanks.
-
heres what I have so far, there are 4 images, but you get the idea:
Titanium.UI.setBackgroundColor('#000000');
// create root window
var rootWin = Titanium.UI.createWindow({
title:'Title here'
});
var aseriesbutt = Ti.UI.createImageView({
title:"A Series",
image:'buttons/ui/a-button.png',
width:160,
height:240,
left:0,
right:160,
top:0
});aseriesbutt.addEventListener('click',function(e){
Ti.UI.createWindow({
url:'a1.js',
backButtonTitle:'back',
title:'A1'
});
});rootWin.add(aseriesbutt);
rootWin.open();