It's great you got it to work.
But why do you need a separate class (LanguagePack) to get localized 
strings/resources?

In a method of your activity or another context, you could just do: 
getString(R.string.some_string)?

If you want to access localized resources/strings in code that does not 
have a Context readily available, you could create a static singleton of 
your LanguagePack class in the Application object of your app:

public class MyApp extends Application {
  private static LanguagePack myLanguagePack = null;

  ...
  ...

  public LanguagePack getLanguagePack() {
    if (myLanguagePack == null) {
      myLanguagePack = new LanguagePack(this);
    }
    return myLanguagePack;
  }
  ...
  ... 
}


public class LanguagePack {
  private final Context context;
  public LanguagePack(Context context) {
    this.context = context.getApplicationContext();
  }

  public String getString(int resID) {
    return context.getString(resID);
  }
  ...
  ...
}

And everywhere in your code, you could do 
MyApp.getLanguagePack().getString(R.string.some_string);

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to