android 根據圖片名字獲取圖片id

public int getResource(String imageName){  
      Context ctx=getBaseContext();         int resId = getResources().getIdentifier(imageName, "drawable" , ctx.getPackageName());         return resId } 說明:imageName就是在drawable文件夾下的圖片,沒有後綴名
相關文章
相關標籤/搜索