I can not solve this problem within 3 days. I have a simple XML resource for menus
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/categoryEditButton" android:title="@string/edit" android:icon="@drawable/edit" /> <item android:id="@+id/categoryMoveUpButton" android:title="@string/move_up" android:icon="@drawable/up" /> <item android:id="@+id/categoryMoveDownButton" android:title="@string/move_down" android:icon="@drawable/down" /> <item android:id="@+id/categoryDeleteButton" android:title="@string/delete" android:icon="@drawable/trash" /> </menu>
I want to get a List <MenuItem> after parsing this XML:
public class MenuItem { private CharSequence text; private Drawable image; private int actionTag;
I need this for non-standard manipulations with MenuItems and cannot work with this resource with standard methods, for example:
... MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.some_menu, menu); ...
Can someone help me? Thanks.
Dmytro zarezenko
source share