我在我的數據庫中有一列存儲我在Android應用程序中使用的圖像的文件名。在我的大部分活動中,我需要使用很多這些圖像。打開文件名的ArrayList到Android資源
因此,我將這些文件名存儲在ArrayList<String>
中,我希望我的輸出是這些圖像的資源ID的ArrayList<Integer>
。
基於這裏計算器幾個問題,我用下面的技術(got it from this question):
// Where tileImageFilenames is the ArrayList<String>
for(int i=0;i<tileImagesFilename.size();i++)
{
tileImagesIDS.add(getResources().getIdentifier(tileImagesFilename.get(i) , "drawable", getApplication().getPackageName()));
}
這將返回我的ArrayList<Integer>
全0的。
從我的理解java中的泛型不適用於許可證,所以ArrayList是明確的失敗。 –
Raf
2014-09-01 14:58:18
是的,它沒有工作 – tvieira 2014-09-01 15:07:47
是什麼錯誤? – mmlooloo 2014-09-01 15:08:15