1

when i press a button to change a new language from new string values but the layout doesn't changed, how can i do? this is my code:

btnChangeLng.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String language = "lo";
            Locale locale = new Locale(language);
            Locale.setDefault(locale);
            Resources resources = getBaseContext().getResources();
            DisplayMetrics displayMetrics = resources.getDisplayMetrics();
            Configuration configuration = resources.getConfiguration();
            configuration.locale = locale;
            resources.updateConfiguration(configuration, displayMetrics);
            Toast.makeText(Main_Activity.this, "Laos", Toast.LENGTH_LONG).show();

            //refresh here


        }
    });

Language will change when i re-open this app, but it's not automatic change when i press a button, now i want to refresh my layout

Alpha9
  • 101
  • 7

2 Answers2

0

Have you tried doing this Android Localization? You can refresh your current activity.

Change language

Community
  • 1
  • 1
avinea28
  • 11
  • 3
0

First Change the language of device on button click and then fire intent.

public void onClick (View v){
 // Chnage lanuage of your device here
    Intent intent = getIntent();
    finish();
    startActivity(intent);
}
Pankaj Arora
  • 10,224
  • 2
  • 37
  • 59