1

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 ArrayLists, 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>
Siarhei
  • 2,014
  • 2
  • 20
  • 53

1 Answers1

0

You can not modify the value of a variable when the modifier is final.

Check this, it is an example for populate a ListView using a custom adapter and extendig of BaseAdapter.

Hope this help.

Community
  • 1
  • 1
Angel Guevara
  • 438
  • 4
  • 14
  • thanks, i don't want to change it. it's items set, like menu, but menu not allows to store custom extensions. so, the question it: where i need to store item settings (links to resources\images\texts\ext) – Siarhei Jul 18 '16 at 18:26