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());
}
Post a Comment for "Notfoundexception When Looking For Drawable Resource"