Pregunta

enter image description here

in v4.fragment, i set setHasOptionsMenu(true); and then in onCreateOptionsMenu i set inflater.inflate(R.menu.menu_fragment, menu);, everything is ok until i switch language.

when the app is running, and i press home-key, open setting, change locale language, select my running app from recently app list, the option menu in actionbar will increase duplicate menuitem, what's happen?

¿Fue útil?

Solución

Gemini, I know it is late and you most probably have the answer already. The easiest way to fix this issue is to just add menu.clear();

public void onPrepareOptionsMenu(Menu menu) {
  MenuInflater inflater = new MenuInflater(getActivity().getApplicationContext());

  menu.clear();

  super.onPrepareOptionsMenu(menu);
  inflater.inflate(R.menu.myMenu, menu);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top