Android在更改语言环境后,drawables不会';t更新

Android在更改语言环境后,drawables不会';t更新,android,Android,我的应用程序支持两种语言,用户可以在运行时进行更改。我有一个Utils类,方法是: public static void changeLocale(Activity context, String lang) { Resources res = context.getResources(); // Change locale settings in the app. DisplayMetrics dm = res.getDisplayMetrics

我的应用程序支持两种语言,用户可以在运行时进行更改。我有一个Utils类,方法是:

public static void changeLocale(Activity context, String lang) {
        Resources res = context.getResources();
        // Change locale settings in the app.
        DisplayMetrics dm = res.getDisplayMetrics();
        android.content.res.Configuration conf = res.getConfiguration();
        conf.locale = new Locale(lang.toLowerCase());
        res.updateConfiguration(conf, dm);
    }
从活动中调用此方法后,我也调用finish()方法

if (changed) {
            Utils.changeLocale(this, Settings.getStringProperty(Settings.APP_LANGUAGE, ""));
            setResult(LANG_CHANGED);
        }

        finish();
在更改语言后,所有字符串都会成功更改,但我还需要更改一些可绘图项。。。我的活动具有initContnet()方法:

private void initContent(){
System.out.println(“lang:+Settings.getLanguage());
setContentView(右布局、主导航);
按钮放置(选项卡1,findViewById(R.id.btn1));
按钮放置(选项卡2,findViewById(R.id.btn2));
按钮放置(选项卡3,findViewById(R.id.btn3));
按钮。放置(选项卡4,findViewById(R.id.btn4));
按钮。放置(TAB_5,findViewById(R.id.btn5));
//设置单击侦听器
集合BTN=按钮。值();
用于(视图五:基站){
v、 setOnClickListener(此);
}
makeDefaultselection();
}
并且正确地检测到语言(当我更改语言时,更改的语言是printet)。此外,所有的字符串都被转换。。。但drawables保持不变,直到我关闭应用程序并再次运行它(之后drawables也会改变)

是否有任何方法可以手动刷新所有绘图

需要明确的是,这里有来自main_navigation.xml文件的框架:

 <LinearLayout
        android:id="@+id/navigation_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@drawable/nav_back"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:weightSum="5" >

        <Button
            android:id="@+id/btn1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/templates_btn_selector"
            android:contentDescription="@string/app_name" />

下面是butn_选择器,它指向我要刷新的drawable:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/templates_selected" android:state_selected="true"/>
    <item android:drawable="@drawable/templates"/>

</selector>


您可能正在为每种语言使用通用的可绘制文件和单独的字符串文件

为不同语言添加单独的图像资源,如

res-> drawable-en-> templates_selected.png
res-> drawable-ar-> templates_selected.png
res-> drawable-fr-> templates_selected.png

可能您正在为每种语言使用公共可绘制文件和单独的字符串文件,请添加不同的可绘制文件夹,如drawable-[language code]
我的应用程序支持两种语言,用户可以在运行时更改它。
-有操作系统设置,不要在你的应用程序中执行。@ArunShankar-非常感谢,我有单独的值和drawable-[phone size](如:drawable ge hdpi和drawable hdpi)文件夹,但我有选择器文件的普通drawable文件夹。。我刚刚将这些选择器xml文件复制到drawable ge文件夹并解决了问题非常感谢,我有单独的值和drawable-[phone size](比如:drawable ge hdpi和drawable hdpi)文件夹,但我有选择器文件的公共drawable文件夹。。我只是将这些选择器xml文件复制到drawable ge文件夹中,问题就解决了
res-> drawable-en-> templates_selected.png
res-> drawable-ar-> templates_selected.png
res-> drawable-fr-> templates_selected.png