0
不加載圖片我改變這個INT []變遷INT []以IntArray導致應用
int[] imageID;
= {
R.drawable.farm_small,
R.drawable.scroll_small,
R.drawable.desert_small,
R.drawable.bg_blue_small,
R.drawable.city_small,
R.drawable.clip_small,
R.drawable.grass_small,
R.drawable.green_leaves_small,
R.drawable.moon_landscape_small,
R.drawable.prismatic_floruish_small,
R.drawable.technologic_small,
R.drawable.white_small,
R.drawable.red_small,
R.drawable.bllue_small,
R.drawable.yellow_small
};
這在string.xml
<array name="drawable_positions">
<item>@drawable/farm_small</item>
<item>@drawable/scroll_small</item>
<item>@drawable/desert_small</item>
<item>@drawable/bg_blue_small</item>
<item>@drawable/city_small</item>
<item>@drawable/clip_small</item>
<item>@drawable/grass_small</item>
<item>@drawable/green_leaves_small</item>
<item>@drawable/moon_landscape_small</item>
<item>@drawable/prismatic_floruish_small</item>
<item>@drawable/technologic_small</item>
<item>@drawable/white_small</item>
<item>@drawable/red_small</item>
<item>@drawable/bllue_small</item>
<item>@drawable/yellow_small</item>
</array>
和我的init這裏的一切:imageID = res.getIntArray(R.array.drawable_positions);
但現在當我加入這個圖像的菜單,我看不到它們。我不知道爲什麼。
這裏是myAdapter:
RecyclerViewForBackground mAdapter = new RecyclerViewForBackground(web, imageID);
,這裏是構造它:
RecyclerViewForBackground(String[] web, int[] img) {
this.web = web;
this.img = img;
}
調用後什麼是圖像標識值res.getIntArray()? – UneXp
請參閱@UneXp答案。爲了一致性,你不應該把它放在'string.xml'中,因爲它應該包含字符串資源。創建另一個文件並將其稱爲'integer.xml'或'array.xml'或'resources.xml'或類似的東西。 –