Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用不同的语言引用ImageButton_Android - Fatal编程技术网

Android 如何使用不同的语言引用ImageButton

Android 如何使用不同的语言引用ImageButton,android,Android,我有一个文本视图(语言)和两个单选按钮(中文)和(英文)以及一个保存按钮,在同一个布局中。我的问题是,在选择了一种语言后,当我单击“保存”按钮时,我的文本视图(语言)会相应更改,但我的按钮(保存)不会刷新 我的代码是: if (lang_selected.equalsIgnoreCase("English")) { Locale locale = new Locale("es"); Locale.setDefault(locale); Confi

我有一个文本视图(语言)和两个单选按钮(中文)和(英文)以及一个保存按钮,在同一个布局中。我的问题是,在选择了一种语言后,当我单击“保存”按钮时,我的文本视图(语言)会相应更改,但我的按钮(保存)不会刷新

我的代码是:

 if (lang_selected.equalsIgnoreCase("English")) {
        Locale locale = new Locale("es");
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale; 
        context.getResources().updateConfiguration(config,context.getResources().getDisplayMetrics());
        //initView(view);

    }else if(lang_selected.equalsIgnoreCase("Chinese")){
        Locale locale = new Locale("zh");
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale; 
        context.getResources().updateConfiguration(config,context.getResources().getDisplayMetrics());
        //initView(view);
    }
我正在尝试刷新我的文本视图文本和图像按钮:

 txtLanguage_onLanguageScreen.setText(getString(R.string.language));
    saveBtnlanguage.setImageResource(R.drawable.general_info_save_button);

如果问题是图像没有变为中国国旗,则
您必须提供本地化的可绘图文件夹。
i、 e.:可绘制zh中文图形资源

如果您支持多个分辨率,还必须添加dpi:
i、 e.:可提取zh xhdpi用于xhdpi(~320 dpi)资源

在这里,您可以放置中国国旗,而在drawable(drawable xhdpi)中,您可以放置英国国旗。
因为英语是默认的语言,所以不需要指定“en”

您的values.zh文件夹中包含文件strings.xml(我假设您正在使用,因为其余的都可以正常工作),应该在一个名为“language”的字符串中包含“Save”的中文版本(与您在英文版本中使用的相同)


毕竟,建议您深入阅读和。

在您的“值”文件夹中提供“保存”文本的中文版本。创建一个文件夹值zh,并提供中文的string.xml。

所以,问题是图像没有更改为中文标志?是的,但是有ImageButton而不是图像