0

I've been doing quite a few programs in VBA epecially for EXCEL. Now I'm trying to do one for my android phone.

I usually have it so you can choose your own language. If I do it like I did it in VBA it would probably look like something below.

But where do I put it? A class by itself or in my main class?

It is important that it is accesible from all classes as well as runnable threads/handlers and so on. Suggestions ?

int language = 2; //2 For swedish

Button cancelButton = (Button) findViewById(R.id.button04);
cancelButton.setText(getTranslation(1, language));


public String getTranslation(int textItem, int language) {
    String returnValue;
    String dictionary="01Cancel@Avbryt@Cancelado@02Yes@Ja@Si@03No@Nej@No@04Continue@Fortsätt@Continuar@"

    // Code to extract Stringnr 'textItem' of the language 'language'

    return returnValue; 
}
Emil
  • 2,786
  • 20
  • 24
Tomas F.
  • 318
  • 3
  • 14
  • Do you want to access the function `getTranslation(int textItem, int language)` globally ? – Gekkula Aug 24 '15 at 10:41
  • Are you aware of the `string.xml` localisation system on android ? – Hacketo Aug 24 '15 at 10:43
  • Thats right, the getTranslation needs to be accesible from everywhere (even runnable threads in other classes. – Tomas F. Aug 24 '15 at 11:21
  • string.xml ? No, never heard or seen anything about it. But I'll google it and see what I find. – Tomas F. Aug 24 '15 at 11:22
  • Refer to global functions and variables at [http://stackoverflow.com/questions/1944656/android-global-variable](http://stackoverflow.com/questions/1944656/android-global-variable) . @Hacketo suggestion is for [supporting multiple languages](http://developer.android.com/training/basics/supporting-devices/languages.html) – Gekkula Aug 24 '15 at 11:42
  • Actually this string.xml seems to be right up my alley. The major drawback seems you can't change language runtime? Or change the language at all without altering the phones location settings? – Tomas F. Aug 24 '15 at 15:00

0 Answers0