Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; public class Main { /** * Turns a string into an array of drawable resource IDs. * 'string' must contain string equivalent of valid drawable names without file endings * separated by commas. * @param string * @param context * @return an array of drawable resource IDs */ public static int[] stringToDrawableResIDArray(String string, Context context) { String[] strArray = string.split(","); int[] intArray = new int[strArray.length]; Resources resources; int resId; int i = 0; for (String str : strArray) { resources = context.getApplicationContext().getResources(); intArray[i] = resources.getIdentifier(strArray[i], "drawable", "com.domnibus.sfarinas.youtubetest"); i++; } return intArray; } }