title: AlertDialog.Builder setItems list with another
body: <p>I'm trying to have a list of items that when touched will open another list of items. Rather like a sub menu of items. This is because my first list is getting to long and I would like to group some together into a sub menu.</p>
  
  <pre><code>    gridView.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View v, final int position, long id) {
  
             final CharSequence[] items = {"Gallery Image Menu", "View pattern", "Delete pattern", "Locate pattern in list view", "Row Counter (with pattern)", "Share Pattern", "Share Image", "Cancel"};
  
              AlertDialog.Builder builder = new AlertDialog.Builder(grid.this);
              builder.setTitle(selectedimage);
              builder.setItems(items, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int item) {
  
  
                      if (item == 0){
                          //first menu 1st item
                          dialog.dismiss();
  
                          final CharSequence[] items2 = {"Rotate image 180"+"\u00B0", "Rotate image 90"+"\u00B0", "Add image from pattern",  "Add image from file", "Add image from camera", "Remove image", "Cancel"};
  
                          final AlertDialog.Builder builder2 = new AlertDialog.Builder(grid.this);
                          builder2.setTitle(selectedimage);
                          builder2.setItems(items2, new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog2, int item) {
  
  
                                  if(item == 0){
                                      //2nd menu, 1st item
                                      dialog2.dismiss();
  
                                      //do something
                                      return;
                                  }
  
                                  if(item == 1){
                                      dialog2.dismiss();
                                      //2nd menu, 2nd item
                                      //do something else
                                      return;
                                  }
  
  
                              AlertDialog alert2 = builder2.create();
                              alert2.show();
  
                              }
                          });
                      }
  
  
                      if (item == 1){
                          //first menu 2nd item
                      }
  
  
                      if(item == 2){
                          //1st menu, 3rd item
                      }
  
  
                      if(item == 3){
  
                      }
  
                      //..... etc
  
  
                  }
              });
              AlertDialog alert = builder.create();
              alert.show();
  
  
          }
  
      });//gridView.setOnItemClickListener
  </code></pre>
  
  <p>The first builder displays as expected but when I select the first option which I want to open the 2nd builder the first builder closes and returns to activity.</p>
  
  <p>When in debug mode the 2nd builder code is read as if it was going to display but then both close.</p>
  
  <p>Perhaps you cannot do this?</p>
  
  <p>Any ideas?</p>