我有一组图像 url,我必须首先从中下载图像,然后以滑动方式显示。但我想异步下载图像。我一次使用 3 张图像,如下面的代码:
var imageViewArray = [];
var nextImageIndex;
var imageNameArray=[];
for (var i = 0; i < 3; i++) {
var imageView1 = Titanium.UI.createImageView({
});
imageViewArray[i] = imageView1;
}
var scrollingView = Titanium.UI.createScrollableView({
views : imageViewArray,
width : 310,
height : 450,
top : 5,
left : 5,
borderWidth : 2,
borderColor : '#000'
});
scrollingView.addEventListener('scroll', function(e) {
Ti.API.info("C=" + e.currentPage);
Ti.API.info("N=" + nextImageIndex);
if (e.currentPage == 2 && nextImageIndex < imageNameArray.length - 2) {
//Setting the current page to 1 will allow the smooth swipe functionality
scrollingView.currentPage = 1;
nextImageIndex += 1;
var vw = scrollingView.views[0];
imageViewArray[0] = scrollingView.views[1];
imageViewArray[1] = scrollingView.views[2];
scrollingView.removeView[vw];
vw.image = imageNameArray[nextImageIndex + 1];
imageViewArray[2] = vw;
scrollingView.views = imageViewArray;
} else if (e.currentPage == 0 && nextImageIndex > 1) {
nextImageIndex -= 1;
scrollingView.currentPage = 1;
var vw = scrollingView.views[2];
imageViewArray[1] = scrollingView.views[0];
imageViewArray[2] = scrollingView.views[1];
scrollingView.removeView[vw];
vw.image = imageNameArray[nextImageIndex - 1];
imageViewArray[0] = vw;
scrollingView.views = imageViewArray;
}
});
scrollingView.views[0].image = imageNameArray[0];
scrollingView.views[1].image = imageNameArray[1];
scrollingView.views[2].image = imageNameArray[2];
nextImageIndex = 1;
谁能告诉我我应该在哪里从网址下载图像。谢谢