0

我正在尝试制作一个多语言应用程序,英语和希腊语。我想要的只是第一个屏幕上的 2 个按钮,您将选择语言,然后所有其他应用程序将使用该语言。我做了一个简单的测试项目,有 2 个按钮和一个段落,当你按下英文按钮时,文本将是英文,当你按下希腊语按钮时,文本将是希腊文。我的代码

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_page2);

    Button english = (Button) findViewById(R.id.english);
    english.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Locale locale = new Locale("en_UK"); 
            Locale.setDefault(locale);
            Configuration config = new Configuration();
            config.locale = locale;

            getApplicationContext().getResources().updateConfiguration(config, null);
    Intent intent = new Intent(v.getContext(), MainActivity.class);
            startActivityForResult(intent, 0);
        }

    });
    Button greek = (Button) findViewById(R.id.greek);
    greek.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Locale locale = new Locale("el_GR"); 
            Locale.setDefault(locale);
            Configuration config = new Configuration();
            config.locale = locale;

            getApplicationContext().getResources().updateConfiguration(config, null);
            Intent intent = new Intent(v.getContext(), MainActivity.class);
            startActivityForResult(intent, 0);
        }

    });



}

带有英文段落的 strings.xml 位于原始 res/values 文件夹中,带有希腊语的 strings.xml 位于 res/values-el

这是来自测试应用程序的 3 个屏幕截图这里是一些屏幕截图:

http://s18.postimg.org/dw0dvdsr9/Screenshot_2013_09_04_15_27_58.png

http://s18.postimg.org/6u2g96p5h/Screenshot_2013_09_04_15_28_08.png

http://s18.postimg.org/7kv6eyrit/Screenshot_2013_09_04_15_28_14.png

没有字母的那个是希腊段落

4

1 回答 1

0

问题是您的手机不支持希腊语的Unicode字符,有两种解决方案,

1)这意味着您的设备使用的字体不支持希腊字符(因此unknown unicode)。您需要找到更好的字体并在您的应用程序中使用它(请参阅http://developer.android.com/reference/android/graphics/Typeface.html文档)

2) 获取在线 unicode 转换器或谷歌翻译英语到希腊语并将单词复制到您的 strings.xml

于 2013-09-04T13:13:47.903 回答