How to make a two-language application by changing the language in the settings menu? Android studio

1

I would like to do this manually through a click, Portuguese or English Language. and fetch the correct string.

public boolean onCreateOptionsMenu (Menu menu) {         getMenuInflater (). inflate (R.menu.menu_main, menu);         return true;     }

public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
    
asked by anonymous 21.06.2018 / 00:17

1 answer

2

The best way to do this would be to add different strings.xml in different resource folders, for example:

res/
    values/
           strings.xml // Idioma padrão 
    values-pt-rBr/
           strings.xml // Idioma português Brasil

More on Android's documentation .

Or you can manually change the example of this site .

    
21.06.2018 / 00:51