i have the custom ListView
, each item contains two icons, text, description, ect. it's static data, but i have several lists to display.
At that moment i save all this in final ArrayList
s, like this:
public static final int ACTION_MAIN = 1;
public static final int ACTION_LEFT = 2;
private static final List<ModelMenu> list = new ArrayList<ModelMenu>(){{
add(new ModelMenu(ACTION_MAIN , R.drawable.icon_main, R.drawable.image_main, R.string.main, R.string.main_description, false));
add(new ModelMenu(ACTION_LEFT , R.drawable.icon_left, R.drawable.image_left, R.string.left, R.string.left_description, false));
}};
than pass List
to adapter. in this case i use constants ACTION_MAIN, ACTION_LEFT
, ect. to set it up like view id, and use it to understand which item were clicked in OnItemClickListener
by view.getId()
is it ok? or is better to use for ex. XML like done here
update 0: found one more option, but in this case we need to keep order for all resources...
or any other option is preferable?
update 1: found another way to save actions:
<resources>
<item type="id" name="menu_home"/>
<item type="id" name="menu_login"/>
</resources>