Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Titanium 如何在scrollView(Android支持)中添加视图数组?_Titanium_Titanium Mobile_Titanium Modules - Fatal编程技术网

Titanium 如何在scrollView(Android支持)中添加视图数组?

Titanium 如何在scrollView(Android支持)中添加视图数组?,titanium,titanium-mobile,titanium-modules,Titanium,Titanium Mobile,Titanium Modules,我是钛合金的新应用开发者。我想创建一个基于窗口的应用程序。在iphone、ipad或android平台上运行。 当我在iphone上运行应用程序时,它会正常运行,但当我在Android上运行时,它会显示一个msg(意外错误),然后关闭 var win1 = Titanium.UI.createWindow({ backgroundColor : '#f0f0f0', }); var view1 = Titanium.UI.createView({ height

我是钛合金的新应用开发者。我想创建一个基于窗口的应用程序。在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();
如何在滚动视图中添加阵列。 在阵列i存储中(图像路径)

请帮帮我

提前感谢,

请尝试以下代码:

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();

您不能将数组“添加”到窗口对象-“添加”只接受代理对象-从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();
试试这个

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);
}
var数组=新数组();
数组[0]=“图像路径”;
数组[1]=“图像路径”;
对于(a=0;a
var-array=new-array();
数组[0]=“图像路径”;
数组[1]=“图像路径”;

对于(a=0;aIt在iphone或ipad中正常工作,但在Android中不正常……它是否显示任何行号?不,它的肉体警报和have msg已意外停止,请再试一次两者之间有什么不同,我认为这是相同的,相同的msg flashdi删除了对象中的额外coma并放置在数组中。不,我的问题就在这里。我的应用程序is在iphone模拟器上正常运行,但android出现问题请删除数组代码并检查其是否工作?删除以下行var abc=new array();abc[0]=“images/img.png';abc[1]=“images/img1.png';scrollView1.add(abc);ya,当我发表评论(//scrollView1.add(abc);)时,然后在两个模拟器(iphone或android)中正常运行您好,我想用缩略图显示我的所有图片,在我的图片库中可以找到缩略图视图。我该怎么做,请告诉我。(注意:它在iphone模拟器中正常运行,但在Android上不正常。)在iOS中显示任何图像的事实都很奇怪。要显示图像,您需要创建一个ImageView并将其添加到ScrollView。您下载了厨房水槽并查看了其中的代码吗?这将帮助您更好地理解钛。非常感谢,这对我非常有用(厨房水槽),非常感谢您的回复..使用ImageView而不是标签来显示图像:Ti.UI.createImageView而不是Ti.UI.createLabelok抱歉,我在使用UI对象时遇到一些问题。但是,我有逻辑非常感谢您的回复。。。
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);
}