Skip to content

Instantly share code, notes, and snippets.

@aldakur
Last active June 13, 2016 11:34
Show Gist options
  • Save aldakur/388818ada5890a483b25c0a82e78b5a8 to your computer and use it in GitHub Desktop.
Save aldakur/388818ada5890a483b25c0a82e78b5a8 to your computer and use it in GitHub Desktop.
#android Get Resources
// String resource. normal method
btnRutas.setText(R.string.rutas);
// Get resources dynamically. When string variable is different in some cases
String variable = ruta.getDescripcion(); //For example, now variable is "car_description"
int intVariableForTranslate = context.getResources().getIdentifier(variable, "string", context.getPackageName());
String descriptionTranslated = context.getString(intVariableForTranslate);
// String resource
String myString = getResources().getString(R.string.mystring)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment