Titanium 钛:ListView加载远程图像

Titanium 钛:ListView加载远程图像,titanium,titanium-mobile,Titanium,Titanium Mobile,我有下面的一段代码,可以把用户的facebook联系人列表和他们的个人资料图片一起拉回来,但是这些图片并不是为每个用户加载的,它只是为一些用户显示图片 fb.requestWithGraphPath('me/friends', { fields : 'first_name,last_name,id,installed,picture.width(120).height(120),gender' }, 'GET', function(e) { if (e.s

我有下面的一段代码,可以把用户的facebook联系人列表和他们的个人资料图片一起拉回来,但是这些图片并不是为每个用户加载的,它只是为一些用户显示图片

fb.requestWithGraphPath('me/friends', {
        fields : 'first_name,last_name,id,installed,picture.width(120).height(120),gender'
    }, 'GET', function(e) {
        if (e.success) {
            var d = JSON.parse(e.result);
            var pData = [];
            var iData = [];
            var row = d.data;
            row = row.sort(sortByName)
            for (var i = 0; i < d.data.length; i++) {
                var img = row[i].picture.data.url
                if (row[i].installed) {
                    pData.push({
                        properties : {
                            title : row[i].first_name + " " + row[i].last_name,
                            id : row[i].id,
                            image : img,
                            gender : row[i].gender,
                            accessoryType : Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE
                        },
                        template : Ti.UI.LIST_ITEM_TEMPLATE_DEFAULT
                    });
                } else {
                    iData.push({
                        properties : {
                            title : row[i].first_name + " " + row[i].last_name,
                            id : row[i].id,
                            image : img,
                            accessoryType : Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE
                        },
                        template : Ti.UI.LIST_ITEM_TEMPLATE_DEFAULT
                    });

                }
            }
            var play = Ti.UI.createListSection({
                headerTitle : 'Play with Facebook Friends',
                items : pData
            });

            var invite = Ti.UI.createListSection({
                headerTitle : 'Invite Facebook Friends',
                items : iData
            });
            var listView = Ti.UI.createListView({
                sections : [play, invite],
            });
            self.add(listView)
        } else {
            alert("Facebook Error");
        }
    })
fb.requestWithGraphPath(“我/朋友”{
字段:“名字、姓氏、id、已安装、图片、宽度(120)、高度(120)、性别”
}“获取”函数(e){
如果(如成功){
var d=JSON.parse(e.result);
var pData=[];
var iData=[];
var行=d数据;
行=行。排序(sortByName)
对于(变量i=0;i
图像存储在
var img=row[i].picture.data.url
中,并作为
image:img
的一部分推送到数据数组中,但并非所有图像都在加载


有没有办法强制加载图像?并在加载时显示一个默认图像?

这里有一个链接,用于完成示例,以完成您试图完成的操作


很好,这似乎奏效了。看起来需要在ListView中添加图像,然后使用模板进行定义。很高兴它帮助了您,向alloy的过渡并非微不足道,但其好处使其值得付出努力