Get Resource By Name
Hy! I have in my /values/strings.xml: Bad Request Not Found
Solution 1:
If you want to get resource id dynamically, according to error code for example, you need to use getIdentifier()
e.g.
String err_code = ...;
int strId = context.getResources().getIdentifier("error" + err_code, "string", "packagename");
if (strId != 0)
Toast.maketext(context, context.getString(strId), Toast.LENGTH_LONG).show();
else
Toast.maketext(context, "Unknown error", Toast.LENGTH_LONG).show();
Post a Comment for "Get Resource By Name"