public void imgIdtoArray() { ArrayList Icon = new ArrayList<>(); //假設有50張圖 for (int i = 0; i < 50; i++) { //每張圖片的檔名 → no_1,no_2,no_3..... String name = "no_" + i; ballIcon.add(getResources() .getIdentifier(name, "drawable", getPackageName())); } }