Changing Locale within the app itself

前端 未结 6 1920
遇见更好的自我
遇见更好的自我 2020-11-22 01:31

My users can change the Locale within the app (they may want to keep their phone settings in English but read the content of my app in French, Dutch or any other language ..

6条回答
  •  没有蜡笔的小新
    2020-11-22 01:42

    If you want to effect on the menu options for changing the locale immediately.You have to do like this.

    //onCreate method calls only once when menu is called first time.
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        //1.Here you can add your  locale settings . 
        //2.Your menu declaration.
    }
    //This method is called when your menu is opend to again....
    @Override
    public boolean onMenuOpened(int featureId, Menu menu) {
        menu.clear();
        onCreateOptionsMenu(menu);
        return super.onMenuOpened(featureId, menu);
    }
    

提交回复
热议问题