-2

I have a parsed xml file and now I want to create a dynamic UI in a hierarchically way. For example:

1
   1.1
   1.2
2
   2.1 
3
   3.1
   3.1.1

Every menu that has a submenu is tagged with a name "menu", and the menu that is an action is tagged as "action". Can you please help me in implementing this? I know the logic is wrong, I'm currently working on it but here is what I'm trying to do:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    this.mymenu=menu;
    Iterator<Option> it= optionList.iterator();
    int count=0;
    while(it.hasNext()){
        Option e= (Option)it.next();
        if(e.getType().equals("menu")){
            count++;
            menu.add(0,count,0,e.getName());
        }
    }


    getMenuInflater().inflate(R.menu.parser, menu);
    return true;
}
Arnestig
  • 2,285
  • 18
  • 30
user1511085
  • 1
  • 1
  • 5
  • 1
    *"ne help will be gr8...."* Spelling words properly will be great! Please also fix that stuck '.' key. – Andrew Thompson Jul 23 '12 at 07:00
  • seriously, if you can't help in this then please don't just write anything. – user1511085 Jul 23 '12 at 08:55
  • *"..if you can't help.."* Oh, I thought you might be more concerned about the 3 people who looked at your question, don't speak text-message, and left it for one they could understand. My bad. – Andrew Thompson Jul 23 '12 at 08:59

1 Answers1

0

Use like this

public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
SubMenu sub = menu.addSubMenu(0,1,0, "SubMenu");
sub.add(0,11,0,"SubMenu 1");
sub.add(0,12,0,"SubMenu 2");
sub.add(0,13,0,"SubMenu 3");
return true;
}

For more details check here

Shalini
  • 1,733
  • 4
  • 17
  • 31
  • thanks shalini....can u pls help me in creating a submenu inside a submenu.... submenu -> submenu 1 -> submenu 11 – user1511085 Jul 23 '12 at 07:00