There is an item menu item. It is necessary that when you click on this item, the icon of this item changes and after the application is restarted, it retains the same icon. How to programmatically set it seems to understand:
item.setIcon(R.drawable.ic_english_flag_24dp);
But after clicking on the button, recreate () happens to change the interface language, and as I understand it, the menu is redrawn from the original xml again.
Menu code:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:icon="@drawable/ic_russian_flag_24dp" android:id="@+id/action_language" android:orderInCategory="1" android:title="@string/action_language" app:showAsAction="always" /> <item android:id="@+id/action_about" android:orderInCategory="2" android:title="@string/action_about" app:showAsAction="never" /> </menu>
How can I save the desired image for the icon?