@Override
 public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
   mDidAction = true;
   dismiss();
   final MenuItem item = mAdapter.getItem(position);
   if (item.hasSubMenu()) {
     showMenu(item.getSubMenu());
   } else {
     if (mItemClickListener != null) {
       mItemClickListener.onMenuItemClick(item);
     }
   }
 }
 private void showMenu(Menu menu) {
   mAdapter.setMenu(menu);
   mWindow.show();
 }