Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 6th, 2013  |  syntax: None  |  size: 2.04 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. getExpandableListView().setOnGroupClickListener(
  2.             new OnGroupClickListener() {
  3.                 @Override
  4.                 public boolean onGroupClick(ExpandableListView parent,
  5.                         View v, int groupPosition, long id) {
  6.                     if (groupPosition == 1) {
  7.                         Toast.makeText(getApplicationContext(), "TEST",
  8.                                 Toast.LENGTH_SHORT).show();
  9.                     } else if (groupPosition != lastExpandedGroupPosition) {
  10.                         getExpandableListView().collapseGroup(
  11.                                 lastExpandedGroupPosition);
  12.                     } else
  13.                         getExpandableListView().expandGroup(groupPosition);
  14.                     lastExpandedGroupPosition = groupPosition;
  15.  
  16.                     return true;
  17.                 }
  18.             });
  19.        
  20. mExpandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
  21.         public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
  22.             if(groupPosition == 2) {
  23.                 Toast.makeText(mContext, "Group 2 clicked", Toast.LENGTH_LONG).show();
  24.                 return true;
  25.             } else
  26.                 return false;
  27.         }
  28.     });
  29.        
  30. private int previousGroupPosition = -1;
  31. private boolean isDoubleTap = false;    
  32.  
  33. expLv.setOnGroupClickListener(new OnGroupClickListener()
  34. {
  35.     @Override
  36.     public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id)
  37.     {
  38.         if(previousGroupPosition != -1)
  39.             expLvTodoCategories.collapseGroup(previousGroupPosition);
  40.  
  41.         if(previousGroupPosition != groupPosition || isDoubleTap)
  42.         {
  43.             isDoubleTap = false;
  44.             previousGroupPosition = groupPosition;
  45.             if(groupPosition == 1)
  46.             {
  47.                  //Start Activity
  48.             }
  49.             else
  50.             {
  51.                 expLv.expandGroup(groupPosition);
  52.             }
  53.         }
  54.         else
  55.             isDoubleTap = true;
  56.  
  57.         return true;
  58.     }
  59. });
clone this paste RAW Paste Data