2014-03-19 80 views
-1

如何將圖像存儲在二維數組中?將圖像存儲在二維數組中?

ImageView iv1[]= new ImageView[20]; 
    int mylist1[]={R.drawable.step_000,R.drawable.step_001,R.drawable.step_002,R.drawable.step_003,R.drawable.step_004, 
      R.drawable.step_005,R.drawable.step_006,R.drawable.step_007,R.drawable.step_008,R.drawable.step_009,R.drawable.step_010, 
      R.drawable.step_011,R.drawable.step_012,R.drawable.step_013,R.drawable.step_014,R.drawable.step_015,R.drawable.step_016, 
      R.drawable.step_017,R.drawable.step_018,R.drawable.step_019}; 
    ImageView iv4[] = new ImageView[20]; 
    int mylist2[]={R.drawable.step_100,R.drawable.step_101,R.drawable.step_102,R.drawable.step_103,R.drawable.step_104, 
      R.drawable.step_105,R.drawable.step_106,R.drawable.step_107,R.drawable.step_108,R.drawable.step_109,R.drawable.step_110, 
      R.drawable.step_111,R.drawable.step_112,R.drawable.step_113,R.drawable.step_114,R.drawable.step_115,R.drawable.step_116, 
      R.drawable.step_117,R.drawable.step_118,R.drawable.step_119}; 

回答

0

與多維數組

int mylist1[][]= 
    {{R.drawable.step_000,R.drawable.step_001,R.drawable.step_002, 
    R.drawable.step_003,R.drawable.step_004, R.drawable.step_005, 
    R.drawable.step_006,R.drawable.step_007,R.drawable.step_008, 
    R.drawable.step_009,R.drawable.step_010,R.drawable.step_011, 
    R.drawable.step_012,R.drawable.step_013,R.drawable.step_014, 
    R.drawable.step_015,R.drawable.step_016,R.drawable.step_017, 
    R.drawable.step_018,R.drawable.step_019}, 
    {R.drawable.step_100,R.drawable.step_101,R.drawable.step_102, 
    R.drawable.step_103,R.drawable.step_104,R.drawable.step_105, 
    R.drawable.step_106,R.drawable.step_107,R.drawable.step_108, 
    R.drawable.step_109,R.drawable.step_110,R.drawable.step_111, 
    R.drawable.step_112,R.drawable.step_113,R.drawable.step_114, 
    R.drawable.step_115,R.drawable.step_116, R.drawable.step_117, 
    R.drawable.step_118,R.drawable.step_119} }; 
0

舉一個簡單的建設Java嘗試:

對於R.id.*

int[][] mas = new int[][]{ 
     {1,2,3}, 
     {2,4,5} 
}; 

對於ImageView's

ImageView[][] mas = new ImageView[][]{ 
     {image1,image2,image3}, 
     {image4,image5,image6} 
}; 
相關問題