這可能是一個我可能再次忽略的問題,但如果你能幫我解決它,我將非常感謝。使用此代碼 擺脫繪製圖像並將其發送到Imageview.setImageResource(在我的ImageView是一個gridview內);一切正常Android使用ArrayList在ImageView上加載圖像
private Integer[] imageIDs = {
//R.drawable.image1,
R.drawable.image2,
R.drawable.image3,
R.drawable.image4,
R.drawable.image5,
R.drawable.image6,
R.drawable.Image7,
};
//Here is my another code to call imageIDs as ImageResource
ImageView iv = (ImageView)v.findViewById(R.id.grid_item_picture);
iv.setImageResource(imageIDs[position]);
//position is a default value of gridview starting from 0
現在我要完成的是刪除數組轉換它僅僅是因爲需要這些內部數據是動態的。所以香港專業教育學院創建這些新代碼
ArrayList<String> array_image = new ArrayList<String>();
array_image.add("R.drawable.image6");
array_image.add("R.drawable.image1");
和ImageView的ImageResource設置爲這個代碼
iv.setImageResource(array_image .get(position));
我收到一個錯誤說:在
的方法setImageResource(INT)類型的ImageView不適用於參數(對象) 你能幫我解決/找出它嗎?
我已經嘗試過,先生,但是它仍然是給我一個錯誤說 image6不能得到解決或無法在現場 – Janwel
W8先生生病再試一次我想我再造一個語法錯誤 – Janwel
現在我得到這個錯誤「ImageView類型中的方法setImageResource(int)不適用於我的代碼iv.setImageResource(array_image.get(position))上的參數(Object)」; – Janwel