Last active
June 13, 2016 11:34
-
-
Save aldakur/388818ada5890a483b25c0a82e78b5a8 to your computer and use it in GitHub Desktop.
#android Get Resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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