Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

several images and event listeners of images in imageview in ios

$
0
0

Application type:Mobile,Titanium SDK:3.3,Titanium studio:3.3,platform & version:ios 7.1,device:ios simulator ,OS:Mac OSX 10.9.3

var win1 = Ti.UI.createWindow({
    backgroundColor : 'white'
});
var view1 = Ti.UI.createView({
    width : '100',
    height : '100',
    backgroundColor : '#fff'
});
win1.add(view1);
 
try {
    var db, dbrow;
    db = Ti.Database.open('mydb');
    dbrow = db.execute('SELECT linkout,ad_screen,name,id,image from advertisement where ad_screen=?', 'Events');
 
    var dbimages = [];
    var xhr = Titanium.Network.createHTTPClient();
    xhr.onload = function() {
        try {
 
            var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'iPicad.png');
            f.write(this.responseData);
            if (f.exists) {
                dbimages[0] = [f.nativePath];
                //Ti.API.info(dbimages[0]);
            }
        } catch(e) {
            //Ti.API.info(e);
        }
    };
    xhr.open('GET', 'url=' + dbrow.fieldByName('image'));
    xhr.send();
var image = Ti.UI.createImageView({
        width : Ti.UI.SIZE,
        height : Ti.UI.FILL,
        images : dbimages
    });
    view1.add(image);
    Ti.API.info(dbimages[0]);
 
    Ti.API.info(dbimages.length);
    if (image.getAnimating() === false) {
        Ti.API.info('start');
        image.start();
    }
    dbrow.close();
    db.close();
} catch(SQLException) {
    db.close();
}
win1.open();
image is not displaying in the imageview and the array length is showing as 0.How can I get the image in imageview and have seperate event listener for images array.

Viewing all articles
Browse latest Browse all 8068

Trending Articles