Skip to content Skip to sidebar Skip to footer

Notfoundexception When Looking For Drawable Resource

I am starting with android and I want to add a border to cells as described in this answer. So I created my cell_background.xml file, which Eclipse created in res\drawable and that

Solution 1:

The problem is that you use Resources.getSystem(), which will give you a reference to the system resources. You should use context.getResources() instead.

Solution 2:

Try with the following code to check whether the resource exists or not

int drawRes = getDrawableResourceID(context, "cell_background"));
if(drawRes>0){
getResources().getDrawable(drawRes);
}

//To detect whether the reource exits in drawable or notpublicstaticintgetDrawableResourceID(Context context,
                String identifierName){

            return context.getResources().getIdentifier(identifierName,
                    "drawable", context.getPackageName());
        }

Solution 3:

not sure about issue regarding putting in Drawable folder only i haven't got issue any, Still try using this way tht i use generally

Drawabledrawable= getResources().getDrawable(R.drawable.cell_background);

Post a Comment for "Notfoundexception When Looking For Drawable Resource"