title: add menu items dynamically and programatically in android
body: <pre><code>@Override
  public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) {
  
  
      new Thread(new Runnable() {
  
          @Override
          public void run() {
              AdminSoapService adminSoapService = new AdminSoapService();
              final List&lt;String&gt; packageNamesList = adminSoapService.getPackagesFromSumarClientByClientCnp("1840805160041");
              String[] packageNames = packageNamesList.toArray(new String[packageNamesList.size()]);
              packagesViews = SQLMceHelper.getDb(getActivity()).getPackagesByPackageNames(packageNames);
  
              getActivity().runOnUiThread(new Runnable() {
  
                  @Override
                  public void run() {
                      for (int i = 0; i &lt; packagesViews.size(); i++) {
  
                          String name = packagesViews.get(i).getName();
                          String path = packagesViews.get(i).getTileRenderPath();
                          int id = packagesViews.get(i).getId();                          
  
                          MenuItem edit_item = menu.add(Menu.NONE, id , i, name);
                          edit_item.setIcon(Drawable.createFromPath(path));
                          edit_item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
                          edit_item.setOnMenuItemClickListener(SCFragment.this);
  
                      }                       
                  }
              });
  
  
          }
      }).start();
  
      super.onCreateOptionsMenu(menu, inflater);
  }
  </code></pre>
  
  <p>The problems with the above code are the following:
  1: if is room only the image is displayed
  2: if is not room only the text is displayed into a secondary menu</p>
  
  <p>I need to display both image and text if is room and if is not and also I want that the text to be below the image.</p>