0

私はチタンの新しいアプリ開発者です。ウィンドウベースのアプリを作りたい。iphone、ipad、または android プラットフォームで実行されます。iPhoneでアプリケーションを実行すると、正しく実行されますが、Androidで実行すると、メッセージ(予期しないエラー)が表示され、その後閉じられます。

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

配列をウィンドウ オブジェクトに「追加」することはできません。「追加」は、Titanium Proxy オブジェクト (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 に答える