0

我是 Titanium 的新应用程序开发人员。我想创建一个基于窗口的应用程序。在 iphone 或 ipad 或 android 平台上运行。当我在 iphone 上运行应用程序而不是正常运行时,但是当我在 Android 上运行时,它会显示一个 msg(意外错误),然后它就关闭了。

var win1 = Titanium.UI.createWindow({   
   backgroundColor : '#f0f0f0',      
}); 

var view1 = Titanium.UI.createView({    
height  : 100,  
width   : 100,  
backgroundColor : '#ff0000',
borderColor  : '#000',

}); 

var scrollView1 = Titanium.UI.createScrollView({    
contentHeight   : 150,  
backgroundColor : '#00ff00',

});

var abc = new Array();

abc[0] = 'images/img.png',

abc[1] = 'images/img1.png',

scrollView1.add(abc); 

view1.add(scrollView1); 

win1.add(view1);

win1.open();

我如何在滚动视图中添加数组。在我存储的数组中(图像路径)

请帮我,

提前致谢,

4

4 回答 4

0

试试这个代码:

var win1 = Titanium.UI.createWindow({   
   backgroundColor : '#f0f0f0'      
}); 

var view1 = Titanium.UI.createView({    
height  : 100,  
width   : 100,  
backgroundColor : '#ff0000',
borderColor  : '#000'

}); 

var scrollView1 = Titanium.UI.createScrollView({    
contentHeight   : 150,  
backgroundColor : '#00ff00'

});

var abc = ['images/img.png','images/img1.png'];

scrollView1.add(abc); 

view1.add(scrollView1); 

win1.add(view1);

win1.open();
于 2012-02-14T13:16:11.707 回答
0

您不能将数组“添加”到窗口对象——“添加”只接受 Titanium 代理对象——从 Ti.UI.create.... 方法返回的东西——作为参数。请参阅下面的注释代码:

var win1 = Titanium.UI.createWindow({   
  backgroundColor : '#f0f0f0',      
}); 

var view1 = Titanium.UI.createView({    
  height  : 100,  
  width   : 100,  
  backgroundColor : '#ff0000',
  borderColor  : '#000',
}); 

var scrollView1 = Titanium.UI.createScrollView({    
  contentHeight   : 150,  
  backgroundColor : '#00ff00',
});

var abc = ['images/img.png', 'images/img1.png'];

// if you want the image paths available as a variable, just set it
scrollView1.abc = abc;
// But I don't understand why you are doing this - you can just access the paths
// from abc directly 

view1.add(scrollView1); 

// You were adding the scroll view twice: win1.add(scrollView1);
// You want to add the view:
win1.add(view1);

win1.open();
于 2012-02-14T23:19:27.213 回答
0

试试这个,

var array = new Array();
array[0] = 'image path';
array[1] = 'image path';

for(a = 0; a<array.length;a++){
var lab1            = Titanium.UI.createLabel({
   backgroundImage      : array1[a],
   height           : 75,
   width            : 75,
   backgroundColor          : '#712347',
   borderRadius         : '10',
   zIndex           : 11,
   });

scrLabel.add(lab1);
}

我,认为这是支持的,为你。

于 2012-02-15T13:17:23.453 回答
0
var array = new Array();
array[0] = 'image path';
array[1] = 'image path';

for(a = 0; a<array.length;a++){
var lab1            = Titanium.UI.createImageView({
   backgroundImage      : array1[a],
   height           : 75,
   width            : 75,
   backgroundColor          : '#712347',
   borderRadius         : '10',
   zIndex           : 11,
   });

scrLabel.add(lab1);
}
于 2012-02-15T13:20:42.180 回答