title: Sub menu in java android without using xml
body: <p>I have a parsed xml file and now I want to create a dynamic UI in a hierarchically way. For example:</p>
  
  <pre><code>1
     1.1
     1.2
  2
     2.1 
  3
     3.1
     3.1.1
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      this.mymenu=menu;
      Iterator&lt;Option&gt; 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;
  }
  </code></pre>