Localisation P246


Not quite got to the bottom of this but my Intel API 10 emulator would only allow it to be set to English whereas an ARM API 10 and an Intel API 18 both allowed me to change the language to whatever I liked.

I saw a post on stackoverflow that suggests that you can’t change language on Intel emulators but that’s definitely wrong. It may be that Intel API 10 is the troublesome one.

Off now to research changing the locale programmatically…

OK, a little while later, I got this tip from http://stackoverflow.com/questions/2900023/change-language-programatically-in-android and changed my HelloMoonActivity to this and it seems to work. However this approach seems to stray away from the book’s objective as the locale is now hard-wired into the code.

[code]import java.util.Locale;

import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class HelloMoonActivity extends FragmentActivity {

protected void onCreate(Bundle savedInstanceState) {
	// setContentView(R.layout.activity_hello_moon);

	// Substitute the 2 letter abbreviation below for your language of
	// choice i.e. en for English, es for Spanish etc. etc.
	String languageToLoad = "es";
	Locale locale = new Locale(languageToLoad);
	Configuration config = new Configuration();
	config.locale = locale;